Luna/kernel/src/sys/usleep.cpp
apio dc766e1da7
Some checks failed
Build and test / build (push) Has been cancelled
kernel: Rework VFS access checking + add processes
VFS functions now accept a single Process* pointer instead of credentials and groups.
There is now a distinction between processes and threads
Now to fix all the bugs... waitpid crashes the process with an NX error...
2024-12-06 21:35:59 +01:00

20 lines
468 B
C++

#include "Pledge.h"
#include "sys/Syscall.h"
#include "thread/Scheduler.h"
#include <sys/types.h>
Result<u64> sys_usleep(Registers*, SyscallArgs args)
{
useconds_t us = (useconds_t)args[0];
auto* current = Scheduler::current();
TRY(check_pledge(current->process, Promise::p_stdio));
// FIXME: Allow usleep() to use a more precise resolution.
if (us < 1000) return 0;
kernel_sleep(us / 1000);
return current->sleep_ticks_left.load();
}