Changeset 4e83bb7 for tests/unified_locking/pthread_locks.cfa
- Timestamp:
- Jun 23, 2022, 1:41:29 PM (17 months ago)
- Branches:
- ADT, ast-experimental, master, pthread-emulation, qualifiedEnum
- Children:
- d28524a
- Parents:
- 1dbbef6
- File:
-
- 1 edited
Legend:
- Unmodified
- Added
- Removed
-
tests/unified_locking/pthread_locks.cfa
r1dbbef6 r4e83bb7 3 3 #include <stdlib.hfa> 4 4 #include <thread.hfa> 5 #include <time.h> 6 #include <stdlib.hfa> 5 7 6 const unsigned int num_times = 50 000;8 const unsigned int num_times = 50; 7 9 8 10 simple_owner_lock l; 9 11 pthread_cond_var( simple_owner_lock ) c; 12 13 owner_lock l2; 14 condition_variable( owner_lock ) c2; 10 15 11 16 volatile int counter = 0; … … 59 64 } 60 65 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 61 83 int main() { 62 processor p[ 3];84 processor p[1]; 63 85 printf("Start Test 1: lock and condition variable single wait/notify\n"); 64 86 { … … 78 100 } 79 101 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"); 80 108 }
Note: See TracChangeset
for help on using the changeset viewer.