30 lines
850 B
C
30 lines
850 B
C
#pragma once
|
|
|
|
#include "kthread.h"
|
|
|
|
struct wait_queue {
|
|
struct kthread *thread;
|
|
struct wait_queue *next;
|
|
struct wait_queue *prev;
|
|
};
|
|
|
|
int wait(struct wait_queue *);
|
|
int wake_up(struct wait_queue *);
|
|
|
|
#define wait_event(wq, condition) \
|
|
do { \
|
|
if (condition) \
|
|
break; \
|
|
wait(wq); \
|
|
} while (1)
|
|
|
|
struct semaphore {
|
|
int count;
|
|
struct wait_queue *wait;
|
|
};
|
|
|
|
struct mutex {
|
|
struct kthread *owner;
|
|
struct wait_queue *wait;
|
|
};
|