Ignore:
Timestamp:
Nov 8, 2017, 5:43:33 PM (8 years ago)
Author:
Aaron Moss <a3moss@…>
Branches:
ADT, aaron-thesis, arm-eh, ast-experimental, cleanup-dtors, deferred_resn, demangler, enum, forall-pointer-decay, jacob/cs343-translation, jenkins-sandbox, master, new-ast, new-ast-unique-expr, new-env, no_list, persistent-indexer, pthread-emulation, qualifiedEnum, resolv-new, with_gc
Children:
954908d
Parents:
78315272 (diff), e35f30a (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

File:
1 edited

Legend:

Unmodified
Added
Removed
  • src/tests/sched-int-wait.c

    r78315272 r3f7e12cb  
     1//---------------------------------------------------------
     2// Multi wait test
     3// Ensures that no deadlock from waiting/signalling conditions
     4//---------------------------------------------------------
     5
     6
    17#include <fstream>
    28#include <kernel>
     
    3541//----------------------------------------------------------------------------------------------------
    3642// Tools
    37 void signal( condition * cond, global_t & mutex a, global_t & mutex b ) {
     43void signal( condition & cond, global_t & mutex a, global_t & mutex b ) {
    3844        signal( cond );
    3945}
    4046
    41 void signal( condition * cond, global_t & mutex a, global_t & mutex b, global_t & mutex c ) {
     47void signal( condition & cond, global_t & mutex a, global_t & mutex b, global_t & mutex c ) {
    4248        signal( cond );
    4349}
    4450
    45 void wait( condition * cond, global_t & mutex a, global_t & mutex b ) {
     51void wait( condition & cond, global_t & mutex a, global_t & mutex b ) {
    4652        wait( cond );
    4753}
    4854
    49 void wait( condition * cond, global_t & mutex a, global_t & mutex b, global_t & mutex c ) {
     55void wait( condition & cond, global_t & mutex a, global_t & mutex b, global_t & mutex c ) {
    5056        wait( cond );
    5157}
     
    5662
    5763        while( waiter_left != 0 ) {
    58                 unsigned action = (unsigned)rand48() % 4;
     64                unsigned action = random( 4 );
    5965                switch( action ) {
    6066                        case 0:
    61                                 signal( &condABC, globalA, globalB, globalC );
     67                                signal( condABC, globalA, globalB, globalC );
    6268                                break;
    6369                        case 1:
    64                                 signal( &condAB , globalA, globalB );
     70                                signal( condAB , globalA, globalB );
    6571                                break;
    6672                        case 2:
    67                                 signal( &condBC , globalB, globalC );
     73                                signal( condBC , globalB, globalC );
    6874                                break;
    6975                        case 3:
    70                                 signal( &condAC , globalA, globalC );
     76                                signal( condAC , globalA, globalC );
    7177                                break;
    7278                        default:
     
    8288void main( WaiterABC & this ) {
    8389        for( int i = 0; i < N; i++ ) {
    84                 wait( &condABC, globalA, globalB, globalC );
     90                wait( condABC, globalA, globalB, globalC );
    8591        }
    8692
     
    9298void main( WaiterAB & this ) {
    9399        for( int i = 0; i < N; i++ ) {
    94                 wait( &condAB , globalA, globalB );
     100                wait( condAB , globalA, globalB );
    95101        }
    96102
     
    102108void main( WaiterAC & this ) {
    103109        for( int i = 0; i < N; i++ ) {
    104                 wait( &condAC , globalA, globalC );
     110                wait( condAC , globalA, globalC );
    105111        }
    106112
     
    112118void main( WaiterBC & this ) {
    113119        for( int i = 0; i < N; i++ ) {
    114                 wait( &condBC , globalB, globalC );
     120                wait( condBC , globalB, globalC );
    115121        }
    116122
     
    121127// Main
    122128int main(int argc, char* argv[]) {
    123         rand48seed( time( NULL ) );
     129        random_seed( time( NULL ) );
    124130        waiter_left = 4;
    125131        processor p[2];
Note: See TracChangeset for help on using the changeset viewer.