-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy patht1.c
More file actions
42 lines (33 loc) · 715 Bytes
/
t1.c
File metadata and controls
42 lines (33 loc) · 715 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
/*
* Test Program T1 - Thread Creation
*/
#include <stdio.h>
#include "ud_thread.h"
void function(int thr_id)
{
int i, j;
for (i = j = 0; i < 3; i++, j++) {
printf("this is thread %d [%d]...\n", thr_id, j);
t_yield();
}
printf("Thread %d is done...\n", thr_id);
t_terminate();
}
int main(void)
{
int i;
t_init();
t_create(function, 1, 1);
printf("This is main(1)...\n");
t_create(function, 2, 1);
printf("This is main(2)...\n");
t_create(function, 3, 1);
for (i = 0; i < 4; i++) {
printf("This is main(3)[%d]...\n", i);
t_yield();
}
printf("Begin shutdown...\n");
t_shutdown();
printf("Done with shutdown...\n");
return 0;
}