summaryrefslogtreecommitdiff
path: root/kernel/source/syscall.cpp
diff options
context:
space:
mode:
Diffstat (limited to 'kernel/source/syscall.cpp')
-rw-r--r--kernel/source/syscall.cpp30
1 files changed, 28 insertions, 2 deletions
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 <hilbert/kernel/paging.hpp>
#include <hilbert/kernel/input.hpp>
#include <hilbert/kernel/panic.hpp>
+#include <hilbert/kernel/timer.hpp>
#include <hilbert/kernel/vfile.hpp>
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;
}