Changeset c7816be


Ignore:
Timestamp:
Jun 24, 2020, 2:47:04 PM (4 years ago)
Author:
Thierry Delisle <tdelisle@…>
Branches:
ADT, arm-eh, ast-experimental, enum, forall-pointer-decay, jacob/cs343-translation, master, new-ast, new-ast-unique-expr, pthread-emulation, qualifiedEnum
Children:
8ae4165
Parents:
52769ba
Message:

fixed disjoint test

File:
1 edited

Legend:

Unmodified
Added
Removed
  • tests/concurrent/signal/disjoint.cfa

    r52769ba rc7816be  
    2121#endif
    2222
     23// This tests checks what happens when someone barges in the midle of the release
     24// of a bulk of monitors.
     25
    2326enum state_t { WAIT, SIGNAL, BARGE };
    2427
    2528monitor global_t {};
    26 global_t mut;
    2729
    2830monitor global_data_t;
     
    3335        int counter;
    3436        state_t state;
    35 } data;
     37};
     38
     39// Use a global struct because the order needs to match with Signaller thread
     40struct {
     41        global_t mut;
     42        global_data_t data;
     43} globals;
    3644
    3745condition cond;
     
    4048
    4149void ?{}( global_data_t & this ) {
    42         this.counter == 0;
     50        this.counter = 0;
    4351        this.state = BARGE;
    4452}
     
    5967void main( Barger & this ) {
    6068        while( !all_done ) {
    61                 barge( data );
     69                barge( globals.data );
    6270                yield();
    6371        }
     
    8694
    8795void main( Waiter & this ) {
    88         while( wait( mut, data ) ) { KICK_WATCHDOG; yield(); }
     96        while( wait( globals.mut, globals.data ) ) { KICK_WATCHDOG; yield(); }
    8997}
    9098
     
    98106
    99107void logic( global_t & mutex a ) {
    100         signal( cond, a, data );
     108        signal( cond, a, globals.data );
    101109
    102110        yield( random( 10 ) );
    103111
    104112        //This is technically a mutual exclusion violation but the mutex monitor protects us
    105         bool running = TEST(data.counter < N) && data.counter > 0;
    106         if( data.state != SIGNAL && running ) {
    107                 sout | "ERROR Eager signal" | data.state;
     113        bool running = TEST(globals.data.counter < N) && globals.data.counter > 0;
     114        if( globals.data.state != SIGNAL && running ) {
     115                sout | "ERROR Eager signal" | globals.data.state;
    108116        }
    109117}
     
    116124void main( Signaller & this ) {
    117125        while( !all_done ) {
    118                 logic( mut );
     126                logic( globals.mut );
    119127                yield();
    120128        }
Note: See TracChangeset for help on using the changeset viewer.