diff --git a/definitions/objects/thread.def b/definitions/objects/thread.def index 4e30a60..8ac3c8c 100644 --- a/definitions/objects/thread.def +++ b/definitions/objects/thread.def @@ -18,6 +18,6 @@ object thread : object { } method sleep [static] { - param until uint64 + param duration uint64 } } diff --git a/src/kernel/syscalls/thread.cpp b/src/kernel/syscalls/thread.cpp index 0d3c01e..22349c4 100644 --- a/src/kernel/syscalls/thread.cpp +++ b/src/kernel/syscalls/thread.cpp @@ -1,6 +1,7 @@ #include #include +#include "clock.h" #include "logger.h" #include "objects/process.h" #include "objects/thread.h" @@ -47,11 +48,13 @@ thread_kill(thread *self) } j6_status_t -thread_sleep(uint64_t til) +thread_sleep(uint64_t duration) { thread &th = thread::current(); - log::debug(logs::task, "Thread %llx sleeping until %llu", th.koid(), til); + uint64_t til = clock::get().value() + duration; + + log::debug(logs::task, "Thread %llx sleeping until %llu", th.koid(), til); th.set_wake_timeout(til); th.block(); return j6_status_ok;