kernel: finish implementation of private and shared futexes

This commit is contained in:
2026-03-18 20:57:51 +00:00
parent b774415f64
commit 2a1a0cf14d
10 changed files with 254 additions and 29 deletions

37
syscall/futex.c Normal file
View File

@@ -0,0 +1,37 @@
#include <kernel/futex.h>
#include <kernel/sched.h>
#include <kernel/syscall.h>
#include <kernel/task.h>
kern_status_t sys_futex_wait(
kern_futex_t *futex,
kern_futex_t new_val,
unsigned int flags)
{
struct task *self = current_task();
if (!validate_access_r(self, futex, sizeof *futex)) {
return KERN_MEMORY_FAULT;
}
futex_key_t key;
kern_status_t status = futex_get(futex, &key, flags);
if (status != KERN_OK) {
return status;
}
return futex_wait(key, new_val, flags);
}
kern_status_t sys_futex_wake(
kern_futex_t *futex,
unsigned int nr_waiters,
unsigned int flags)
{
futex_key_t key;
kern_status_t status = futex_get(futex, &key, flags);
if (status != KERN_OK) {
return status;
}
return futex_wake(key, nr_waiters, flags);
}