Ignore:
File:
1 edited

Legend:

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

    r303406a r4cedd9f  
     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}
     
    5359//----------------------------------------------------------------------------------------------------
    5460// Signaler
    55 void main( Signaler* this ) {
     61void main( Signaler & this ) {
    5662
    5763        while( waiter_left != 0 ) {
    58                 unsigned action = (unsigned)rand48() % 4;
     64                unsigned action = rand48(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:
     
    8086//----------------------------------------------------------------------------------------------------
    8187// Waiter ABC
    82 void main( WaiterABC* this ) {
     88void 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
     
    9096//----------------------------------------------------------------------------------------------------
    9197// Waiter AB
    92 void main( WaiterAB* this ) {
     98void main( WaiterAB & this ) {
    9399        for( int i = 0; i < N; i++ ) {
    94                 wait( &condAB , &globalA, &globalB );
     100                wait( condAB , globalA, globalB );
    95101        }
    96102
     
    100106//----------------------------------------------------------------------------------------------------
    101107// Waiter AC
    102 void main( WaiterAC* this ) {
     108void main( WaiterAC & this ) {
    103109        for( int i = 0; i < N; i++ ) {
    104                 wait( &condAC , &globalA, &globalC );
     110                wait( condAC , globalA, globalC );
    105111        }
    106112
     
    110116//----------------------------------------------------------------------------------------------------
    111117// Waiter BC
    112 void main( WaiterBC* this ) {
     118void main( WaiterBC & this ) {
    113119        for( int i = 0; i < N; i++ ) {
    114                 wait( &condBC , &globalB, &globalC );
     120                wait( condBC , globalB, globalC );
    115121        }
    116122
Note: See TracChangeset for help on using the changeset viewer.