kernel: finish implementation of private and shared futexes
This commit is contained in:
@@ -48,6 +48,8 @@ static const virt_addr_t syscall_table[] = {
|
||||
VM_CONTROLLER_SUPPLY_PAGES,
|
||||
vm_controller_supply_pages),
|
||||
SYSCALL_TABLE_ENTRY(KERN_OBJECT_WAIT, kern_object_wait),
|
||||
SYSCALL_TABLE_ENTRY(FUTEX_WAIT, futex_wait),
|
||||
SYSCALL_TABLE_ENTRY(FUTEX_WAKE, futex_wake),
|
||||
};
|
||||
static const size_t syscall_table_count
|
||||
= sizeof syscall_table / sizeof syscall_table[0];
|
||||
|
||||
37
syscall/futex.c
Normal file
37
syscall/futex.c
Normal 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);
|
||||
}
|
||||
Reference in New Issue
Block a user