1
Fork 0
mirror of https://github.com/RGBCube/serenity synced 2025-06-01 08:18:12 +00:00

LibPthread: Implement condition variables

This feels like a pretty naive implementation, but I think it can work.
Basically each waiter creates an object on its stack that is then
added to a linked list inside by the pthread_cond_t.

Signalling is then done by walking the list and unsetting the "waiting"
flag on as many of the waiters as you like.
This commit is contained in:
Andreas Kling 2019-12-07 14:24:09 +01:00
parent db2bfe14e9
commit cc1ef6dadb
3 changed files with 109 additions and 2 deletions

View file

@ -66,10 +66,16 @@ typedef void* pthread_once_t;
typedef uint32_t pthread_mutex_t;
typedef void* pthread_attr_t;
typedef void* pthread_mutexattr_t;
typedef void* pthread_cond_t;
typedef struct __pthread_cond_t {
void* storage;
} pthread_cond_t;
typedef void* pthread_rwlock_t;
typedef void* pthread_rwlockatrr_t;
typedef void* pthread_spinlock_t;
typedef void* pthread_condattr_t;
typedef struct __pthread_condattr_t {
int clockid; // clockid_t
} pthread_condattr_t;
__END_DECLS