- File:
-
- 1 edited
-
tests/unified_locking/pthread_locks.cfa (modified) (3 diffs)
Legend:
- Unmodified
- Added
- Removed
-
tests/unified_locking/pthread_locks.cfa
r4e83bb7 r55422cf 3 3 #include <stdlib.hfa> 4 4 #include <thread.hfa> 5 #include <time.h>6 #include <stdlib.hfa>7 5 8 const unsigned int num_times = 50 ;6 const unsigned int num_times = 50000; 9 7 10 8 simple_owner_lock l; 11 9 pthread_cond_var( simple_owner_lock ) c; 12 13 owner_lock l2;14 condition_variable( owner_lock ) c2;15 10 16 11 volatile int counter = 0; … … 64 59 } 65 60 66 thread Wait_Time_Signal_1 {};67 68 void main( Wait_Time_Signal_1 & this ) {69 for (unsigned int i = 0; i < num_times; i++) {70 lock(l);71 if(empty(c) || random(10) >= 9 ) {72 timespec t;73 clock_gettime(CLOCK_REALTIME, &t);74 timespec waitTime{0,1};75 bool woken = wait(c,l, t + waitTime);76 }else{77 notify_one(c);78 }79 unlock(l);80 }81 }82 83 61 int main() { 84 processor p[ 1];62 processor p[3]; 85 63 printf("Start Test 1: lock and condition variable single wait/notify\n"); 86 64 { … … 100 78 } 101 79 printf("Done Test 3\n"); 102 103 printf("Start Test 4: lock and condition variable single timed wait/notify\n");104 {105 Wait_Time_Signal_1 t1[2];106 }107 printf("Done Test 4\n");108 80 }
Note:
See TracChangeset
for help on using the changeset viewer.