matos/core/wait.h

30 lines
850 B
C
Raw Normal View History

2020-07-08 23:08:50 +02:00
#pragma once
#include "kthread.h"
struct wait_queue {
struct kthread *thread;
struct wait_queue *next;
struct wait_queue *prev;
};
2020-08-15 23:31:35 +02:00
int wait(struct wait_queue *);
int wake_up(struct wait_queue *);
#define wait_event(wq, condition) \
do { \
if (condition) \
break; \
wait(wq); \
} while (1)
2020-07-08 23:08:50 +02:00
struct semaphore {
2020-08-15 23:31:35 +02:00
int count;
struct wait_queue *wait;
2020-07-08 23:08:50 +02:00
};
struct mutex {
2020-08-15 23:31:35 +02:00
struct kthread *owner;
struct wait_queue *wait;
2020-07-08 23:08:50 +02:00
};