forked from nikitadanilov/usched
-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathumain.c
More file actions
48 lines (41 loc) · 736 Bytes
/
umain.c
File metadata and controls
48 lines (41 loc) · 736 Bytes
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
45
46
47
48
#include "usched.h"
#include <stdlib.h>
#include <stdio.h>
enum { NR = 10 };
static struct ustack u[NR] = {};
static int idx = 0;
static struct ustack *_next(struct usched *s)
{
return &u[idx++ % NR];
}
static void *_alloc(struct usched *s, int size)
{
return malloc(size);
}
static void _free(struct usched *s, void *addr, int size)
{
return free(addr);
}
static void f(void *arg)
{
int idx = (long)arg;
int i = 0;
while (1) {
printf("%i:%i\n", idx, i);
ustack_block();
i++;
}
}
int main(int argc, char **argv)
{
int i;
struct usched s = {
.s_next = &_next,
.s_alloc = &_alloc,
.s_free = &_free
};
for (i = 0; i < NR; ++i) {
ustack_init(&u[i], &s, &f, (void *)(long)i, NULL, 0);
}
usched_run(&s);
}