summaryrefslogtreecommitdiff
path: root/kern/thread.c
diff options
context:
space:
mode:
Diffstat (limited to 'kern/thread.c')
-rw-r--r--kern/thread.c15
1 files changed, 15 insertions, 0 deletions
diff --git a/kern/thread.c b/kern/thread.c
index 73e1cfb8..043f14de 100644
--- a/kern/thread.c
+++ b/kern/thread.c
@@ -2555,6 +2555,21 @@ thread_timedsleep(struct spinlock *interlock, const void *wchan_addr,
return thread_sleep_common(interlock, wchan_addr, wchan_desc, true, ticks);
}
+void
+thread_delay(uint64_t ticks, bool absolute)
+{
+ thread_preempt_disable();
+
+ if (!absolute) {
+ /* Add a tick to avoid quantization errors */
+ ticks += clock_get_time() + 1;
+ }
+
+ thread_timedsleep(NULL, thread_self(), "delay", ticks);
+
+ thread_preempt_enable();
+}
+
void __init
thread_run_scheduler(void)
{