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-barge.c

    raf08051 r28e58fd  
    2828};
    2929
    30 void ?{} ( global_data_t * this ) {
    31         this->done = false;
    32         this->counter = 0;
    33         this->state = BARGE;
     30void ?{} ( global_data_t & this ) {
     31        this.done = false;
     32        this.counter = 0;
     33        this.state = BARGE;
    3434
    35         this->do_signal = 6;
    36         this->do_wait1  = 1;
    37         this->do_wait2  = 3;
     35        this.do_signal = 6;
     36        this.do_wait1  = 1;
     37        this.do_wait2  = 3;
    3838}
    3939
    40 void ^?{} ( global_data_t * this ) {}
     40void ^?{} ( global_data_t & this ) {}
    4141
    4242global_t globalA;
     
    4848thread Threads {};
    4949
    50 bool logicC( global_t * mutex a, global_t * mutex b, global_data_t * mutex c ) {
    51         c->counter++;
     50bool logicC( global_t & mutex a, global_t & mutex b, global_data_t & mutex c ) {
     51        c.counter++;
    5252
    53         if( (c->counter % 1000) == 0 ) sout | c->counter | endl;
     53        if( (c.counter % 1000) == 0 ) sout | c.counter | endl;
    5454
    55         int action = c->counter % 10;
     55        int action = c.counter % 10;
    5656
    5757        if( action == 0 ) {
    58                 c->do_signal = max( ((unsigned)rand48()) % 10, 1);
    59                 c->do_wait1 = ((unsigned)rand48()) % (c->do_signal);
    60                 c->do_wait2 = ((unsigned)rand48()) % (c->do_signal);
     58                c.do_signal = max( ((unsigned)rand48()) % 10, 1);
     59                c.do_wait1 = ((unsigned)rand48()) % (c.do_signal);
     60                c.do_wait2 = ((unsigned)rand48()) % (c.do_signal);
    6161
    62                 if(c->do_wait1 == c->do_wait2) sout | "Same" | endl;
     62                if(c.do_wait1 == c.do_wait2) sout | "Same" | endl;
    6363        }
    6464
    65         if( action == c->do_wait1 || action == c->do_wait2 ) {
    66                 c->state = WAIT;
     65        if( action == c.do_wait1 || action == c.do_wait2 ) {
     66                c.state = WAIT;
    6767                wait( &cond );
    6868
    69                 if(c->state != SIGNAL) {
    70                         sout | "ERROR Barging detected" | c->counter | endl;
     69                if(c.state != SIGNAL) {
     70                        sout | "ERROR Barging detected" | c.counter | endl;
    7171                        abort();
    7272                }
    7373        }
    74         else if( action == c->do_signal ) {
    75                 c->state = SIGNAL;
     74        else if( action == c.do_signal ) {
     75                c.state = SIGNAL;
    7676
    7777                signal( &cond );
     
    7979        }
    8080        else {
    81                 c->state = BARGE;
     81                c.state = BARGE;
    8282        }
    8383
    84         if( c->counter >= N ) c->done = true;
    85         return !c->done;
     84        if( c.counter >= N ) c.done = true;
     85        return !c.done;
    8686}
    8787
    88 bool logicB( global_t * mutex a, global_t * mutex b ) {
    89         return logicC(a, b, &globalC);
     88bool logicB( global_t & mutex a, global_t & mutex b ) {
     89        return logicC(a, b, globalC);
    9090}
    9191
    92 bool logicA( global_t * mutex a ) {
    93         return logicB(a, &globalB);
     92bool logicA( global_t & mutex a ) {
     93        return logicB(a, globalB);
    9494}
    9595
    96 void main( Threads* this ) {
    97         while( logicA(&globalA) ) { yield(); };
     96void main( Threads & this ) {
     97        while( logicA(globalA) ) { yield(); };
    9898}
    9999
     
    101101
    102102int main(int argc, char* argv[]) {
    103         rand48seed(0);
    104         processor p;
    105         {
    106                 Threads t[17];
    107                 the_threads = (thread_desc*)t;
    108         }
     103        rand48seed(0);
     104        processor p;
     105        {
     106                Threads t[17];
     107                the_threads = (thread_desc*)t;
     108        }
    109109}
Note: See TracChangeset for help on using the changeset viewer.