memtest probe
[mirrors/Programs.git] / c / pthread_extra / test_pause.c
index 439c6d8d22de9da53d1807b2b42222e835cb03b3..c12de5a36bc614ff960c862601706593dc7e1b12 100644 (file)
@@ -1,3 +1,5 @@
+#define PTHREAD_FREEWHEEL
+
 #include <signal.h>
 #include <pthread.h>
 #include <pthread_extra.h>
@@ -6,6 +8,8 @@
 #include <assert.h>
 #include <unistd.h>
 
+//#define printf(...) (0)
+
 pthread_t main_thread;
 
 void *thread_test(void *arg) {
@@ -13,10 +17,10 @@ void *thread_test(void *arg) {
        //pthread_pause_enable();
        while(1) {
                pthread_nsleep(0, 1000*1000*300);
-               //pthread_pause_all();
-               pthread_pause(main_thread);
+               pthread_pause_all();
                printf("Running%s!\n", (char *)arg);
-               //pthread_unpause_all();
+               pthread_unpause_all();
+               pthread_pause(main_thread);
                pthread_unpause(main_thread);
        }
 }
@@ -50,24 +54,41 @@ int main() {
        while(1) {
                pthread_pause(b);
                pthread_unpause(a);
+               pthread_pause_disable();
+               pthread_pause_disable();
+               pthread_pause_disable();
                printf("SWITCH A:\n");
+               pthread_pause_enable();
+               pthread_pause_enable();
+               pthread_pause_enable();
                pthread_sleep(2);
 
+               pthread_pause_all();
                printf("SWITCH B:\n");
+               pthread_unpause_all();
                pthread_pause(a);
                pthread_unpause(b);
                pthread_sleep(2);
 
+               //pthread_pause_disable();
+               pthread_pause_all();
                printf("SWITCH A+B:\n");
+               pthread_unpause_all();
+               //pthread_pause_enable();
                pthread_unpause(a);
                pthread_unpause(b);
                pthread_sleep(1);
 
+               //pthread_pause_disable();
+               pthread_pause_all();
                printf("SWITCH MAIN ONLY:\n");
+               //pthread_pause_enable();
                pthread_pause_all();
+               //printf("\n");
                pthread_sleep(1);
                printf("SWITCH MAIN A+B:\n");
                pthread_unpause_all();
+               //printf("\n");
                pthread_sleep(1);
        }
 
This page took 0.16649 seconds and 4 git commands to generate.