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:
2026-01-09 22:09:52 +02:00
parent 5c9151d3e9
commit 2961a49dc7
4 changed files with 66 additions and 40 deletions

View File

@@ -346,6 +346,19 @@ namespace Kernel
vaddr_t m_shared_page_vaddr { 0 };
struct futex_t
{
ThreadBlocker blocker;
uint32_t waiters { 0 };
uint32_t to_wakeup { 0 };
};
static BAN::HashMap<paddr_t, BAN::UniqPtr<futex_t>> s_futexes;
static Mutex s_futex_lock;
BAN::HashMap<paddr_t, BAN::UniqPtr<futex_t>> m_futexes;
Mutex m_futex_lock;
BAN::Vector<Thread*> m_threads;
struct pthread_info_t