mirror of
https://github.com/RGBCube/serenity
synced 2025-05-29 17:35:06 +00:00
Kernel+LibPthread: Implement pthread_join()
It's now possible to block until another thread in the same process has exited. We can also retrieve its exit value, which is whatever value it passed to pthread_exit(). :^)
This commit is contained in:
parent
c6a8b95643
commit
69efa3f630
9 changed files with 117 additions and 5 deletions
|
@ -1,10 +1,11 @@
|
|||
#include <AK/StdLibExtras.h>
|
||||
#include <Kernel/Syscall.h>
|
||||
#include <pthread.h>
|
||||
#include <unistd.h>
|
||||
|
||||
extern "C" {
|
||||
|
||||
int pthread_create(pthread_t* thread, pthread_attr_t* attributes, void *(*start_routine)(void*), void* argument_to_start_routine)
|
||||
int pthread_create(pthread_t* thread, pthread_attr_t* attributes, void* (*start_routine)(void*), void* argument_to_start_routine)
|
||||
{
|
||||
if (!thread)
|
||||
return -EINVAL;
|
||||
|
@ -21,4 +22,9 @@ void pthread_exit(void* value_ptr)
|
|||
exit_thread(value_ptr);
|
||||
}
|
||||
|
||||
int pthread_join(pthread_t thread, void** exit_value_ptr)
|
||||
{
|
||||
int rc = syscall(SC_join_thread, thread, exit_value_ptr);
|
||||
__RETURN_WITH_ERRNO(rc, rc, -1);
|
||||
}
|
||||
}
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue