Changeset d672350 for tests/concurrent/mutexstmt/locks.cfa
- Timestamp:
- Mar 21, 2022, 1:44:06 PM (4 years ago)
- Branches:
- ADT, ast-experimental, enum, master, pthread-emulation, qualifiedEnum
- Children:
- a76202d
- Parents:
- ef3c383 (diff), dbe2533 (diff)
Note: this is a merge changeset, the changes displayed below correspond to the merge itself.
Use the(diff)
links above to see all the changes relative to each parent. - File:
-
- 1 edited
Legend:
- Unmodified
- Added
- Removed
-
tests/concurrent/mutexstmt/locks.cfa
ref3c383 rd672350 3 3 4 4 const unsigned int num_times = 10000; 5 6 Duration default_preemption() { return 0; } 5 7 6 8 single_acquisition_lock m1, m2, m3, m4, m5; … … 22 24 } 23 25 26 void refTest( single_acquisition_lock & m ) { 27 mutex ( m ) { 28 assert(!insideFlag); 29 insideFlag = true; 30 assert(insideFlag); 31 insideFlag = false; 32 } 33 } 34 24 35 thread T_Multi {}; 25 36 26 37 void main( T_Multi & this ) { 27 38 for (unsigned int i = 0; i < num_times; i++) { 39 refTest( m1 ); 28 40 mutex ( m1 ) { 29 41 assert(!insideFlag); … … 59 71 } 60 72 61 thread T_Mutex_Scoped {}; 73 single_acquisition_lock l1; 74 linear_backoff_then_block_lock l2; 75 owner_lock l3; 62 76 63 void main( T_Mutex_Scoped & this ) { 77 monitor monitor_t {}; 78 79 monitor_t l4; 80 81 thread T_Multi_Poly {}; 82 83 void main( T_Multi_Poly & this ) { 64 84 for (unsigned int i = 0; i < num_times; i++) { 65 { 66 scoped_lock(single_acquisition_lock) s{m1}; 67 count++; 68 } 69 { 70 scoped_lock(single_acquisition_lock) s{m1}; 85 refTest( l1 ); 86 mutex ( l1, l4 ) { 71 87 assert(!insideFlag); 72 88 insideFlag = true; … … 74 90 insideFlag = false; 75 91 } 76 } 77 } 78 79 thread T_Multi_Scoped {}; 80 81 void main( T_Multi_Scoped & this ) { 82 for (unsigned int i = 0; i < num_times; i++) { 83 { 84 scoped_lock(single_acquisition_lock) s{m1}; 92 mutex ( l1, l2, l3 ) { 85 93 assert(!insideFlag); 86 94 insideFlag = true; … … 88 96 insideFlag = false; 89 97 } 90 { 91 scoped_lock(single_acquisition_lock) s1{m1}; 92 scoped_lock(single_acquisition_lock) s2{m2}; 93 scoped_lock(single_acquisition_lock) s3{m3}; 94 scoped_lock(single_acquisition_lock) s4{m4}; 95 scoped_lock(single_acquisition_lock) s5{m5}; 98 mutex ( l3, l1, l4 ) { 96 99 assert(!insideFlag); 97 100 insideFlag = true; … … 99 102 insideFlag = false; 100 103 } 101 { 102 scoped_lock(single_acquisition_lock) s1{m1}; 103 scoped_lock(single_acquisition_lock) s3{m3}; 104 assert(!insideFlag); 105 insideFlag = true; 106 assert(insideFlag); 107 insideFlag = false; 108 } 109 { 110 scoped_lock(single_acquisition_lock) s1{m1}; 111 scoped_lock(single_acquisition_lock) s2{m2}; 112 scoped_lock(single_acquisition_lock) s4{m4}; 113 assert(!insideFlag); 114 insideFlag = true; 115 assert(insideFlag); 116 insideFlag = false; 117 } 118 { 119 scoped_lock(single_acquisition_lock) s1{m1}; 120 scoped_lock(single_acquisition_lock) s3{m3}; 121 scoped_lock(single_acquisition_lock) s4{m4}; 122 scoped_lock(single_acquisition_lock) s5{m5}; 104 mutex ( l1, l2, l4 ) { 123 105 assert(!insideFlag); 124 106 insideFlag = true; … … 131 113 int num_tasks = 10; 132 114 int main() { 133 processor p[ 10];115 processor p[num_tasks - 1]; 134 116 135 117 printf("Start Test: single lock mutual exclusion\n"); 136 118 { 137 T_Mutex t[ 10];119 T_Mutex t[num_tasks]; 138 120 } 139 121 assert(count == num_tasks * num_times); … … 141 123 printf("Start Test: multi lock deadlock/mutual exclusion\n"); 142 124 { 143 T_Multi t[ 10];125 T_Multi t[num_tasks]; 144 126 } 145 127 printf("End Test: multi lock deadlock/mutual exclusion\n"); 146 147 count = 0; 148 printf("Start Test: single scoped lock mutual exclusion\n"); 128 printf("Start Test: multi polymorphic lock deadlock/mutual exclusion\n"); 149 129 { 150 T_Mu tex_Scoped t[10];130 T_Multi_Poly t[num_tasks]; 151 131 } 152 assert(count == num_tasks * num_times); 153 printf("End Test: single scoped lock mutual exclusion\n"); 154 printf("Start Test: multi scoped lock deadlock/mutual exclusion\n"); 155 { 156 T_Multi_Scoped t[10]; 157 } 158 printf("End Test: multi scoped lock deadlock/mutual exclusion\n"); 132 printf("End Test: multi polymorphic lock deadlock/mutual exclusion\n"); 159 133 }
Note:
See TracChangeset
for help on using the changeset viewer.