forked from cahirwpz/mimiker
-
Notifications
You must be signed in to change notification settings - Fork 0
/
sleepq.c
44 lines (31 loc) · 820 Bytes
/
sleepq.c
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
#include <stdc.h>
#include <sleepq.h>
#include <thread.h>
int main() {
thread_t t1, t2;
sleepq_t sq1, sq2;
memset(&t1, 0, sizeof(t1));
memset(&sq1, 0, sizeof(sq1));
memset(&t2, 0, sizeof(t2));
memset(&sq2, 0, sizeof(sq2));
t1.td_sleepqueue = &sq1;
t2.td_sleepqueue = &sq2;
void *wchan = (void *)0x123;
sleepq_add(wchan, NULL, &t1);
sleepq_add(wchan, NULL, &t2);
sleepq_signal(wchan);
sleepq_signal(wchan);
sleepq_add(wchan, NULL, &t2);
sleepq_add(wchan, NULL, &t1);
sleepq_broadcast(wchan);
void *wchan2 = (void *)0x124;
sleepq_add(wchan, NULL, &t1);
sleepq_add(wchan2, NULL, &t2);
sleepq_signal(wchan);
sleepq_signal(wchan2);
sleepq_add(wchan, NULL, &t1);
sleepq_add(wchan2, NULL, &t2);
sleepq_remove(&t1, wchan);
sleepq_remove(&t2, wchan2);
return 0;
}