blob: 65a787c0f40a7c9591b0151f99fbcc1a044b0436 (
plain)
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
|
#include <libtf/tf.h>
#include <stdio.h>
struct ctx {
int id;
};
static void work_fiber(void *ptr)
{
struct ctx *c = (struct ctx*) ptr;
printf("Hello%d.1\n", c->id);
tf_yield();
printf("Hello%d.2\n", c->id);
}
static void init_fiber(void *ptr)
{
struct ctx *c;
int i;
for (i = 0; i < 6; i++) {
c = tf_fiber_create(work_fiber, sizeof(struct ctx));
c->id = i;
tf_fiber_put(c);
}
}
int main(int argc, char **argv)
{
return tf_main(init_fiber);
}
|