Got the kernel's nose out of cmdline args
[akaros.git] / user / apps / parlib / pthread / pthread_test.c
1 #include <stdlib.h>
2 #include <assert.h>
3 #include <pthread.h>
4 #include <hart.h>
5 #include <stdio.h>
6
7 void* func(void* arg)
8 {
9         int id = (int)arg;
10
11         printf("Hello from pthread %d!\n",id);
12
13         return arg;
14 }
15
16 int main()
17 {
18         int i;
19         pthread_t* t = (pthread_t*)malloc(sizeof(pthread_t)*(hart_max_harts()-1));
20
21         for(i = 0; i < hart_max_harts()-1; i++)
22                 pthread_create(&t[i],NULL,&func,(void*)(i+1));
23
24         for(i = 0; i < hart_max_harts()-1; i++)
25         {
26                 void* x = 0;
27                 pthread_join(t[i],&x);
28                 assert((long)x == i+1);
29         }
30
31         printf("Pthreads joined!  Bye...\n");
32         return 0;
33 }