ADTast-experimentalenumpthread-emulationqualifiedEnum
Last change
on this file since 0b4ddb71 was
623d1c8,
checked in by caparsons <caparson@…>, 2 years ago
|
added test changes
|
-
Property mode set to
100644
|
File size:
1.5 KB
|
Rev | Line | |
---|
[af67ee1] | 1 | #include <mutex_stmt.hfa> |
---|
[a4d098c] | 2 | #include <locks.hfa> |
---|
[623d1c8] | 3 | #include <stats.hfa> |
---|
[a4d098c] | 4 | |
---|
| 5 | const unsigned int num_times = 10000; |
---|
| 6 | |
---|
[bbe3719] | 7 | single_acquisition_lock m1, m2, m3, m4, m5; |
---|
[a4d098c] | 8 | |
---|
| 9 | thread T_Mutex {}; |
---|
| 10 | bool insideFlag = false; |
---|
| 11 | int count = 0; |
---|
| 12 | |
---|
| 13 | void main( T_Mutex & this ) { |
---|
| 14 | for (unsigned int i = 0; i < num_times; i++) { |
---|
| 15 | mutex ( m1 ) count++; |
---|
[af67ee1] | 16 | mutex ( m1 ) { |
---|
[a4d098c] | 17 | assert(!insideFlag); |
---|
| 18 | insideFlag = true; |
---|
| 19 | assert(insideFlag); |
---|
| 20 | insideFlag = false; |
---|
| 21 | } |
---|
| 22 | } |
---|
| 23 | } |
---|
| 24 | |
---|
| 25 | thread T_Multi {}; |
---|
| 26 | |
---|
| 27 | void main( T_Multi & this ) { |
---|
| 28 | for (unsigned int i = 0; i < num_times; i++) { |
---|
| 29 | mutex ( m1 ) { |
---|
| 30 | assert(!insideFlag); |
---|
| 31 | insideFlag = true; |
---|
| 32 | assert(insideFlag); |
---|
| 33 | insideFlag = false; |
---|
| 34 | } |
---|
| 35 | mutex ( m1, m2, m3, m4, m5 ) { |
---|
| 36 | assert(!insideFlag); |
---|
| 37 | insideFlag = true; |
---|
| 38 | assert(insideFlag); |
---|
| 39 | insideFlag = false; |
---|
| 40 | } |
---|
| 41 | mutex ( m3, m1 ) { |
---|
| 42 | assert(!insideFlag); |
---|
| 43 | insideFlag = true; |
---|
| 44 | assert(insideFlag); |
---|
| 45 | insideFlag = false; |
---|
| 46 | } |
---|
| 47 | mutex ( m1, m2, m4 ) { |
---|
| 48 | assert(!insideFlag); |
---|
| 49 | insideFlag = true; |
---|
| 50 | assert(insideFlag); |
---|
| 51 | insideFlag = false; |
---|
| 52 | } |
---|
| 53 | mutex ( m1, m3, m4, m5 ) { |
---|
| 54 | assert(!insideFlag); |
---|
| 55 | insideFlag = true; |
---|
| 56 | assert(insideFlag); |
---|
| 57 | insideFlag = false; |
---|
| 58 | } |
---|
| 59 | } |
---|
| 60 | } |
---|
| 61 | |
---|
[f57f6ea0] | 62 | int num_tasks = 10; |
---|
[a4d098c] | 63 | int main() { |
---|
| 64 | processor p[10]; |
---|
| 65 | |
---|
| 66 | printf("Start Test: single lock mutual exclusion\n"); |
---|
| 67 | { |
---|
[bbe3719] | 68 | T_Mutex t[10]; |
---|
[a4d098c] | 69 | } |
---|
[f57f6ea0] | 70 | assert(count == num_tasks * num_times); |
---|
[a4d098c] | 71 | printf("End Test: single lock mutual exclusion\n"); |
---|
| 72 | printf("Start Test: multi lock deadlock/mutual exclusion\n"); |
---|
| 73 | { |
---|
| 74 | T_Multi t[10]; |
---|
| 75 | } |
---|
| 76 | printf("End Test: multi lock deadlock/mutual exclusion\n"); |
---|
[623d1c8] | 77 | } |
---|
Note: See
TracBrowser
for help on using the repository browser.