mirror of
https://github.com/LadybirdBrowser/ladybird.git
synced 2024-09-20 09:49:15 +03:00
LibPthread: Initialize conditions with realtime clock
All the way back in commit1670ee5aba
, the default clock for condition variables was set to `CLOCK_MONOTONIC`, because there was no other clock available. However, if a condition variable is initialized without any additional attributes by an application, they sometimes assume that the absolute time that is passed to e.g. `pthread_cond_timedwait` is actually based on a realtime clock, as can be seen here in SDL2:6f419bdf5f/src/thread/pthread/SDL_syscond.c (L99)
Additionally, the glibc implementation defaults to a realtime clock:aac54dcd37/nptl/pthread_cond_init.c (L42)
...so we probably should do so as well :^)
This commit is contained in:
parent
ce3a63253a
commit
30580ed7e4
Notes:
sideshowbarker
2024-07-18 00:42:48 +09:00
Author: https://github.com/gmta Commit: https://github.com/SerenityOS/serenity/commit/30580ed7e44 Pull-request: https://github.com/SerenityOS/serenity/pull/11063
@ -48,7 +48,7 @@ int pthread_cond_init(pthread_cond_t* cond, const pthread_condattr_t* attr)
|
||||
{
|
||||
cond->mutex = nullptr;
|
||||
cond->value = 0;
|
||||
cond->clockid = attr ? attr->clockid : CLOCK_MONOTONIC_COARSE;
|
||||
cond->clockid = attr ? attr->clockid : CLOCK_REALTIME_COARSE;
|
||||
return 0;
|
||||
}
|
||||
|
||||
|
Loading…
Reference in New Issue
Block a user