3 #include <pthread_extra.h>
11 void *thread_test(void *arg
) {
12 //Whole process dies if you kill thread immediately before it is pausable
13 //pthread_pause_enable();
15 pthread_nsleep(0, 1000*1000*300);
17 printf("Running%s!\n", (char *)arg
);
18 pthread_unpause_all();
19 pthread_pause(main_thread
);
20 pthread_unpause(main_thread
);
26 main_thread
= pthread_self();
29 pthread_pause_enable(); //Will get inherited by all threads from now on
30 //That way you can be sure it is pausable immediately
31 pthread_extra_create(&a
, NULL
, thread_test
, " A");
32 pthread_extra_create(&b
, NULL
, thread_test
, " B");
37 for(int32_t i = 1;i>0;i++) {
53 printf("SWITCH A:\n");
56 printf("SWITCH B:\n");
61 printf("SWITCH A+B:\n");
66 printf("SWITCH MAIN ONLY:\n");
70 printf("SWITCH MAIN A+B:\n");
71 pthread_unpause_all();
76 pthread_join(a
, NULL
);
77 pthread_join(b
, NULL
);
This page took 0.331998 seconds and 5 git commands to generate.