5 #include <pthread-l4.h>
8 #include <l4/sys/kdebug.h>
11 static int globalcounter;
15 void *thread(void *data)
19 for (unsigned i = 0; i < 10000; ++i) {
20 pthread_mutex_lock(&mtx);
22 pthread_mutex_unlock(&mtx);
24 printf("\033[31mThread: %d\n", globalcounter);
29 int main(int argc, char **argv)
31 (void)argc; (void)argv;
34 pthread_mutex_init(&mtx, 0);
36 int res = pthread_create(&pt, NULL, thread, NULL);
40 for (unsigned i = 0; i < 10000; ++i) {
41 pthread_mutex_lock(&mtx);
43 pthread_mutex_unlock(&mtx);
45 printf("\033[32mMain: %d\n", globalcounter);
48 pthread_join(pt, NULL);
50 enter_kdebug("before return");