![]() ![]() WebKit implementation lacks FUTEX_REQUEUE equivalent, although it is possible to add this if needed.They are NOT the same thing. Unfortunately, performance in contested case will most likely be slower, as it will use futex(2) underneath anyway to block the calling thread, so there is an additional layer of code and locking that needs to be executed. This makes it possible to store less information in synchronization object and be overall smarter with thread scheduling. Mechanism is basically the same as with futex(2), but since it is implemented in userspace it allows execution of custom user code from inside the queue lock. WebKit's ParkingLot is an example of this. NtWaitForKeyedEvent( keyed_event, &variable->Ptr, FALSE, timeout ) Īnother way is to emulate futex-like functionality in userspace. Interlocked_xchg_add( (int *)&variable->Ptr, 1 ) RTL_CONDITION_VARIABLE *variable, RTL_SRWLOCK *lock) Int val = interlocked_xchg( (int *)&variable->Ptr, 0 ) Void WINAPI RtlWakeAllConditionVariable( RTL_CONDITION_VARIABLE *variable ) NtReleaseKeyedEvent( keyed_event, &variable->Ptr, FALSE, NULL) If (interlocked_dec_if_nonzero( (int *)&variable->Ptr )) void WINAPI RtlWakeConditionVariable( RTL_CONDITION_VARIABLE *variable ) Condition variable is just a 4 byte counter of waiters.įollowing code is simplified, you can check the original here. Keyed events are well suited for condition variables, making implemenation is extremely simple. If you want to see more Keyed Events in action, you should check Wine's sources and their implementation of RTL_SRWLOCK and RTL_CONDITION_VARIABLE. Using such API requires having waiter counter in userspace. calling threads is blocked until it actually wakes someone. This mechanism ensures that wake-ups are not missed by making "release" operation blocking e.g. ![]() There are two operations: "wait" and "release" (wake). Just as futex(2), keyed events use table of wait queues hashed by address. They provide alternative undocumented API called "Keyed Events".
0 Comments
Leave a Reply. |
AuthorWrite something about yourself. No need to be fancy, just an overview. ArchivesCategories |