From b1cf9e5dfbc8967bd7cb2a22ec1e5e521f4e0e6e Mon Sep 17 00:00:00 2001 From: Benji Dial Date: Wed, 31 Jul 2024 13:36:53 -0400 Subject: add clock --- kernel/source/syscall.cpp | 30 ++++++++++++++++++++++++++++-- 1 file changed, 28 insertions(+), 2 deletions(-) (limited to 'kernel/source/syscall.cpp') diff --git a/kernel/source/syscall.cpp b/kernel/source/syscall.cpp index c631df1..803f7d2 100644 --- a/kernel/source/syscall.cpp +++ b/kernel/source/syscall.cpp @@ -4,6 +4,7 @@ #include #include #include +#include #include namespace hilbert::kernel::syscall { @@ -800,6 +801,29 @@ namespace hilbert::kernel::syscall { } + void sleep_syscall( + uint64_t &rax, uint64_t &rdi, uint64_t &rsi, uint64_t &rdx) { + + uint64_t mis = rdi; + set_zero(rax, rdi, rsi, rdx); + + auto *t = application::running_thread; + + timer::register_sleeping_thread( + timer::current_time + mis, t); + + application::yield(t->saved_state); + + } + + void get_time_syscall( + uint64_t &rax, uint64_t &rdi, uint64_t &rsi, uint64_t &rdx) { + + set_zero(rax, rdi, rsi, rdx); + rax = timer::current_time; + + } + void (*handlers[])( uint64_t &rax, uint64_t &rdi, uint64_t &rsi, uint64_t &rdx) = { @@ -827,11 +851,13 @@ namespace hilbert::kernel::syscall { &clear_socket_read_queue_syscall, &get_environment_variable_length_syscall, &get_environment_variable_value_syscall, - &set_thread_name_syscall + &set_thread_name_syscall, + &sleep_syscall, + &get_time_syscall }; - static constexpr int max_syscall_number = 24; + static constexpr int max_syscall_number = 26; } -- cgit v1.2.3