matos/core/wait.c
Mathieu Maret 9c6c4f3470 Fix typo
2020-08-16 00:24:59 +02:00

38 lines
621 B
C

#include "wait.h"
#include "irq.h"
#include "kthread.h"
#include "list.h"
int wake_up(struct wait_queue *wq)
{
struct kthread *th;
uint32_t flags;
disable_IRQs(flags);
list_collapse(wq->thread, th)
{
kthreadAddThread(th);
}
restore_IRQs(flags);
return 0;
}
int wait(struct wait_queue *wq)
{
struct kthread *current;
uint32_t flags;
disable_IRQs(flags);
current = getCurrentThread();
kthreadUnsched(current);
list_add_tail(wq->thread, current);
current->state = WAITING;
kthreadSaveAndYield(current);
restore_IRQs(flags);
return 0;
}