Kernel: Optimize futexes
Add support for processor local futexes. These work the exact same way as global ones, but only lock a process specific lock and use a process specific hash map. Also reduce the time futex lock is held. There was no need to hold the global lock while validating addresses in the process' address space.
This commit is contained in:
@@ -884,9 +884,11 @@ int pthread_mutex_unlock(pthread_mutex_t* mutex)
|
||||
mutex->lock_depth--;
|
||||
if (mutex->lock_depth == 0)
|
||||
{
|
||||
const int op = FUTEX_WAKE | (mutex->attr.shared ? 0 : FUTEX_PRIVATE);
|
||||
|
||||
BAN::atomic_store(mutex->futex, 0, BAN::memory_order_release);
|
||||
if (BAN::atomic_load(mutex->waiters))
|
||||
futex(FUTEX_WAKE, &mutex->futex, 1, nullptr);
|
||||
futex(op, &mutex->futex, 1, nullptr);
|
||||
}
|
||||
|
||||
return 0;
|
||||
|
||||
Reference in New Issue
Block a user