diff options
author | Richard Braun <rbraun@sceen.net> | 2017-08-27 16:35:44 +0200 |
---|---|---|
committer | Richard Braun <rbraun@sceen.net> | 2017-08-27 16:35:44 +0200 |
commit | 34541567ab1d1a0ae9f98950d89f7a3769c9d5cb (patch) | |
tree | 4172cd604d3ae475b0c3570bf6c812df143a355b /kern/thread.h | |
parent | 27a8095e93a73341525f7f69051f883f24543427 (diff) |
kern/thread: implement timed sleeps
Diffstat (limited to 'kern/thread.h')
-rw-r--r-- | kern/thread.h | 13 |
1 files changed, 10 insertions, 3 deletions
diff --git a/kern/thread.h b/kern/thread.h index b3bf93f..04eea2b 100644 --- a/kern/thread.h +++ b/kern/thread.h @@ -36,6 +36,7 @@ #include <assert.h> #include <stdbool.h> #include <stddef.h> +#include <stdint.h> #include <stdnoreturn.h> #include <kern/atomic.h> @@ -210,18 +211,24 @@ void thread_join(struct thread *thread); * address should refer to a relevant synchronization object, normally * containing the interlock, but not necessarily. * + * When bounding the duration of the sleep, the caller must pass an absolute + * time in ticks, and ERROR_TIMEDOUT is returned if that time is reached + * before the thread is awaken. + * * Implies a memory barrier. */ void thread_sleep(struct spinlock *interlock, const void *wchan_addr, const char *wchan_desc); +int thread_timedsleep(struct spinlock *interlock, const void *wchan_addr, + const char *wchan_desc, uint64_t ticks); /* * Schedule a thread for execution on a processor. * - * No action is performed if the target thread is NULL, the calling thread, - * or already in the running state. + * If the target thread is NULL, the calling thread, or already in the + * running state, no action is performed and ERROR_INVAL is returned. */ -void thread_wakeup(struct thread *thread); +int thread_wakeup(struct thread *thread); /* * Start running threads on the local processor. |