-
Notifications
You must be signed in to change notification settings - Fork 1
Expand file tree
/
Copy pathm.c
More file actions
32 lines (24 loc) · 693 Bytes
/
m.c
File metadata and controls
32 lines (24 loc) · 693 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
#include "thread.h"
void thread_function(void *arg) {
printf("Thread %s: started\n", (char *)arg);
for(int i = 0; i < 5; i++) {
printf("Thread %s: %d\n", (char *)arg, i);
//schedule();
}
printf("Thread %s: finished\n", (char *)arg);
}
int main() {
my_thread_t thread1, thread2;
if(create_thread(&thread1, thread_function, "1") == -1){
perror("Failed to creat thread1");
return 1;
}
if(create_thread(&thread2, thread_function, "2") == -1){
perror("failed to create thread2");
return 1;
}
printf("Main thread starting\n");
schedule();
printf("Main thread ending\n");
return 0;
}