Ignore:
Timestamp:
Aug 25, 2017, 10:38:34 AM (8 years ago)
Author:
Thierry Delisle <tdelisle@…>
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:
800d275
Parents:
af08051 (diff), 3eab308c (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-disjoint.c

    raf08051 r28e58fd  
    2020
    2121monitor global_data_t;
    22 void ?{}( global_data_t * this );
    23 void ^?{} ( global_data_t * this );
     22void ?{}( global_data_t & this );
     23void ^?{} ( global_data_t & this );
    2424
    2525monitor global_data_t {
     
    3232volatile bool all_done;
    3333
    34 void ?{}( global_data_t * this ) {
    35         this->counter == 0;
    36         this->state = BARGE;
     34void ?{}( global_data_t & this ) {
     35        this.counter == 0;
     36        this.state = BARGE;
    3737}
    3838
    39 void ^?{} ( global_data_t * this ) {}
     39void ^?{} ( global_data_t & this ) {}
    4040
    4141//------------------------------------------------------------------------------
    4242// Barging logic
    43 void barge( global_data_t * mutex d ) {
    44         d->state = BARGE;
     43void barge( global_data_t & mutex d ) {
     44        d.state = BARGE;
    4545}
    4646
    4747thread Barger {};
    4848
    49 void main( Barger * this ) {
     49void main( Barger & this ) {
    5050        while( !all_done ) {
    51                 barge( &data );
     51                barge( data );
    5252                yield();
    5353        }
     
    5656//------------------------------------------------------------------------------
    5757// Waiting logic
    58 bool wait( global_t * mutex m, global_data_t * mutex d ) {
     58bool wait( global_t & mutex m, global_data_t & mutex d ) {
    5959        wait( &cond );
    60         if( d->state != SIGNAL ) {
     60        if( d.state != SIGNAL ) {
    6161                sout | "ERROR barging!" | endl;
    6262        }
    6363
    64         d->counter++;
     64        d.counter++;
    6565
    66         if( (d->counter % 1000) == 0 ) sout | d->counter | endl;
     66        if( (d.counter % 1000) == 0 ) sout | d.counter | endl;
    6767
    68         return d->counter < N;
     68        return d.counter < N;
    6969}
    7070
    7171thread Waiter {};
    7272
    73 void main( Waiter * this ) {
    74         while( wait( &mut, &data ) ) { yield(); }
     73void main( Waiter & this ) {
     74        while( wait( mut, data ) ) { yield(); }
    7575}
    7676
     
    7878//------------------------------------------------------------------------------
    7979// Signalling logic
    80 void signal( condition * cond, global_t * mutex a, global_data_t * mutex b ) {
    81         b->state = SIGNAL;
     80void signal( condition * cond, global_t & mutex a, global_data_t & mutex b ) {
     81        b.state = SIGNAL;
    8282        signal( cond );
    8383}
    8484
    85 void logic( global_t * mutex a ) {
    86         signal( &cond, a, &data );
     85void logic( global_t & mutex a ) {
     86        signal( &cond, a, data );
    8787
    8888        yield( (unsigned)rand48() % 10 );
     
    9797thread Signaller {};
    9898
    99 void main( Signaller * this ) {
     99void main( Signaller & this ) {
    100100        while( !all_done ) {
    101                 logic( &mut );
     101                logic( mut );
    102102                yield();
    103103        }
Note: See TracChangeset for help on using the changeset viewer.