sched: Add sched_sleep_until
This commit is contained in:
@@ -132,6 +132,8 @@ void sched_wake_locked(struct task* task);
|
||||
|
||||
void sched_notify(struct task* task);
|
||||
|
||||
void sched_sleep_until(uint64_t deadline_ns);
|
||||
|
||||
[[noreturn]]
|
||||
void sched_exit();
|
||||
|
||||
|
||||
@@ -4,6 +4,7 @@
|
||||
#include <zinnia/assert.h>
|
||||
#include <zinnia/atomic.h>
|
||||
#include <zinnia/errno.h>
|
||||
#include <zinnia/park.h>
|
||||
#include <zinnia/process.h>
|
||||
#include <zinnia/sched.h>
|
||||
#include <zinnia/spin.h>
|
||||
@@ -157,3 +158,8 @@ void task_lock(struct task* task) {
|
||||
void task_unlock(struct task* task) {
|
||||
spin_unlock(atomic_load(&task->lockp, ATOMIC_RELAXED));
|
||||
}
|
||||
|
||||
void sched_sleep_until(uint64_t deadline_ns) {
|
||||
const uint8_t key = 0;
|
||||
park_timeout(&key, nullptr, nullptr, nullptr, 0, &deadline_ns);
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user