mirror of
https://github.com/Mathewnd/Astral.git
synced 2026-10-29 13:48:21 +00:00
scheduler: sched_usleep
This commit is contained in:
@@ -16,6 +16,7 @@
|
||||
#define IPL_MAX 0
|
||||
#define IPL_TIMER 1
|
||||
#define IPL_KEYBOARD 2
|
||||
#define IPL_NET 400
|
||||
#define IPL_DISK 500
|
||||
#define IPL_DPC 900
|
||||
#define IPL_NORMAL 1000
|
||||
|
||||
@@ -90,5 +90,6 @@ thread_t *sched_newthread(void *ip, size_t kstacksize, int priority, proc_t *pro
|
||||
void sched_destroyproc(proc_t *);
|
||||
void sched_destroythread(thread_t *);
|
||||
void sched_targetcpu(struct cpu_t *cpu);
|
||||
void sched_sleepus(size_t us);
|
||||
|
||||
#endif
|
||||
|
||||
@@ -387,6 +387,19 @@ void sched_targetcpu(cpu_t *cpu) {
|
||||
interrupt_set(intstatus);
|
||||
}
|
||||
|
||||
static void timeout(context_t *, dpcarg_t arg) {
|
||||
thread_t *thread = arg;
|
||||
sched_wakeup(thread, 0);
|
||||
}
|
||||
|
||||
void sched_sleepus(size_t us) {
|
||||
timerentry_t sleepentry = {0};
|
||||
sched_preparesleep(false);
|
||||
|
||||
timer_insert(_cpu()->timer, &sleepentry, timeout, _cpu()->thread, us, false);
|
||||
sched_yield();
|
||||
}
|
||||
|
||||
void sched_init() {
|
||||
threadcache = slab_newcache(sizeof(thread_t), 0, NULL, NULL);
|
||||
__assert(threadcache);
|
||||
|
||||
Reference in New Issue
Block a user