1
Fork 0
mirror of https://github.com/RGBCube/serenity synced 2025-07-28 05:07:35 +00:00

LibC: Rewrite pthread_mutex

pthread_mutex is now an actual "sleeping" mutex, and not just a
spinlock! It still has a fast path that only uses atomics and (in the
successful case) returns immediately without sleeping. In case of
contention, it calls futex_wait(), which lets the kernel scheduler put
this thread to sleep, *and* lets it know exactly when to consider
scheduling it again.
This commit is contained in:
Sergey Bugaev 2021-07-05 14:41:41 +03:00 committed by Andreas Kling
parent 8fee93d868
commit 19bef90923
2 changed files with 83 additions and 51 deletions

View file

@ -18,10 +18,10 @@ void __pthread_fork_atfork_register_prepare(void (*)(void));
void __pthread_fork_atfork_register_parent(void (*)(void));
void __pthread_fork_atfork_register_child(void (*)(void));
int __pthread_mutex_init(pthread_mutex_t*, const pthread_mutexattr_t*);
int __pthread_mutex_lock(pthread_mutex_t*);
int __pthread_mutex_trylock(pthread_mutex_t*);
int __pthread_mutex_unlock(pthread_mutex_t*);
int __pthread_mutex_init(pthread_mutex_t*, const pthread_mutexattr_t*);
typedef void (*KeyDestructor)(void*);