mirror of
https://github.com/RGBCube/serenity
synced 2025-05-31 14:38:11 +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:
parent
db2bfe14e9
commit
cc1ef6dadb
3 changed files with 109 additions and 2 deletions
|
@ -4,6 +4,7 @@
|
|||
#include <stdint.h>
|
||||
#include <sys/cdefs.h>
|
||||
#include <sys/types.h>
|
||||
#include <time.h>
|
||||
|
||||
__BEGIN_DECLS
|
||||
|
||||
|
@ -56,6 +57,8 @@ int pthread_cond_broadcast(pthread_cond_t*);
|
|||
int pthread_cond_init(pthread_cond_t*, const pthread_condattr_t*);
|
||||
int pthread_cond_signal(pthread_cond_t*);
|
||||
int pthread_cond_wait(pthread_cond_t*, pthread_mutex_t*);
|
||||
int pthread_condattr_init(pthread_condattr_t*);
|
||||
int pthread_condattr_setclock(pthread_condattr_t*, clockid_t);
|
||||
int pthread_condattr_destroy(pthread_condattr_t*);
|
||||
int pthread_cancel(pthread_t);
|
||||
int pthread_cond_destroy(pthread_cond_t*);
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue