Changeset c7f2d9b


Ignore:
Timestamp:
Mar 14, 2022, 3:27:04 PM (3 years ago)
Author:
Thierry Delisle <tdelisle@…>
Branches:
ADT, ast-experimental, enum, master, pthread-emulation, qualifiedEnum
Children:
d824715
Parents:
bfb9bf5 (diff), 623d1c8 (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.
Message:

Merge branch 'master' of plg.uwaterloo.ca:software/cfa/cfa-cc

Location:
tests/concurrent/mutexstmt
Files:
2 added
2 edited

Legend:

Unmodified
Added
Removed
  • tests/concurrent/mutexstmt/.expect/locks.txt

    rbfb9bf5 rc7f2d9b  
    33Start Test: multi lock deadlock/mutual exclusion
    44End Test: multi lock deadlock/mutual exclusion
    5 Start Test: single scoped lock mutual exclusion
    6 End Test: single scoped lock mutual exclusion
    7 Start Test: multi scoped lock deadlock/mutual exclusion
    8 End Test: multi scoped lock deadlock/mutual exclusion
  • tests/concurrent/mutexstmt/locks.cfa

    rbfb9bf5 rc7f2d9b  
    11#include <mutex_stmt.hfa>
    22#include <locks.hfa>
     3#include <stats.hfa>
    34
    45const unsigned int num_times = 10000;
     
    5960}
    6061
    61 thread T_Mutex_Scoped {};
    62 
    63 void main( T_Mutex_Scoped & this ) {
    64         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};
    71                         assert(!insideFlag);
    72                         insideFlag = true;
    73                         assert(insideFlag);
    74                         insideFlag = false;
    75                 }
    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};
    85                         assert(!insideFlag);
    86                         insideFlag = true;
    87                         assert(insideFlag);
    88                         insideFlag = false;
    89                 }
    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};
    96                         assert(!insideFlag);
    97                         insideFlag = true;
    98                         assert(insideFlag);
    99                         insideFlag = false;
    100                 }
    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};
    123                         assert(!insideFlag);
    124                         insideFlag = true;
    125                         assert(insideFlag);
    126                         insideFlag = false;
    127                 }
    128         }
    129 }
    130 
    13162int num_tasks = 10;
    13263int main() {
     
    14475        }
    14576        printf("End Test: multi lock deadlock/mutual exclusion\n");
    146        
    147         count = 0;
    148         printf("Start Test: single scoped lock mutual exclusion\n");
    149         {
    150                 T_Mutex_Scoped t[10];
    151         }
    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");     
    15977}
Note: See TracChangeset for help on using the changeset viewer.