439c6d8d22de9da53d1807b2b42222e835cb03b3
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);
16 //pthread_pause_all();
17 pthread_pause(main_thread
);
18 printf("Running%s!\n", (char *)arg
);
19 //pthread_unpause_all();
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");
69 printf("SWITCH MAIN A+B:\n");
70 pthread_unpause_all();
74 pthread_join(a
, NULL
);
75 pthread_join(b
, NULL
);
This page took 0.595888 seconds and 3 git commands to generate.