Luna/kernel/src/sys/alarm.cpp

19 lines
403 B
C++
Raw Normal View History

2023-08-12 19:38:25 +00:00
#include "Pledge.h"
#include "sys/Syscall.h"
#include "thread/Scheduler.h"
Result<u64> sys_alarm(Registers*, SyscallArgs args)
{
unsigned int seconds = (unsigned int)args[0];
auto* current = Scheduler::current();
2023-08-12 19:38:25 +00:00
TRY(check_pledge(current, Promise::p_stdio));
u64 time_left = current->alarm_ticks_left;
current->alarm_ticks_left = seconds * 1000;
return time_left * 1000;
}