Ignore:
Timestamp:
Jan 7, 2021, 3:27:00 PM (5 years ago)
Author:
Thierry Delisle <tdelisle@…>
Branches:
ADT, arm-eh, ast-experimental, enum, forall-pointer-decay, jacob/cs343-translation, master, new-ast-unique-expr, pthread-emulation, qualifiedEnum
Children:
2b4daf2, 64aeca0
Parents:
3c64c668 (diff), eef8dfb (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' into park_unpark

File:
1 edited

Legend:

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

    r3c64c668 r58fe85a  
    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}
     
    5361
    5462thread Barger {};
     63void ?{}( Barger & this ) {
     64        ((thread&)this){ "Barger Thread" };
     65}
    5566
    5667void main( Barger & this ) {
    5768        while( !all_done ) {
    58                 barge( data );
     69                barge( globals.data );
    5970                yield();
    6071        }
     
    7889
    7990thread Waiter {};
     91void ?{}( Waiter & this ) {
     92        ((thread&)this){ "Waiter Thread" };
     93}
    8094
    8195void main( Waiter & this ) {
    82         while( wait( mut, data ) ) { KICK_WATCHDOG; yield(); }
     96        while( wait( globals.mut, globals.data ) ) { KICK_WATCHDOG; yield(); }
    8397}
    8498
     
    92106
    93107void logic( global_t & mutex a ) {
    94         signal( cond, a, data );
     108        signal( cond, a, globals.data );
    95109
    96110        yield( random( 10 ) );
    97111
    98112        //This is technically a mutual exclusion violation but the mutex monitor protects us
    99         bool running = TEST(data.counter < N) && data.counter > 0;
    100         if( data.state != SIGNAL && running ) {
    101                 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;
    102116        }
    103117}
    104118
    105119thread Signaller {};
     120void ?{}( Signaller & this ) {
     121        ((thread&)this){ "Signaller Thread" };
     122}
    106123
    107124void main( Signaller & this ) {
    108125        while( !all_done ) {
    109                 logic( mut );
     126                logic( globals.mut );
    110127                yield();
    111128        }
Note: See TracChangeset for help on using the changeset viewer.