Changeset ccd349d


Ignore:
Timestamp:
May 29, 2017, 11:50:06 AM (4 years ago)
Author:
Thierry Delisle <tdelisle@…>
Branches:
aaron-thesis, arm-eh, cleanup-dtors, deferred_resn, demangler, jacob/cs343-translation, jenkins-sandbox, master, new-ast, new-ast-unique-expr, new-env, no_list, persistent-indexer, resolv-new, with_gc
Children:
4c5b972
Parents:
be3d020
Message:

signal block test now uses wait user info pointer

File:
1 edited

Legend:

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

    rbe3d020 rccd349d  
    1010
    1111monitor global_data_t {
    12         state_t state;
    13         bool ran;
     12        thread_desc * last_thread;
     13        thread_desc * last_signaller;
    1414};
    1515
    1616void ?{} ( global_data_t * this ) {
    17         this->state = BARGE;
     17        this->last_thread = NULL;
     18        this->last_signaller = NULL;
    1819}
    1920
     
    2829//------------------------------------------------------------------------------
    2930void wait_op( global_data_t * mutex a, global_data_t * mutex b, unsigned i ) {
    30         wait( &cond );
    31         a->ran = b->ran = true;
     31        wait( &cond, (uintptr_t)this_thread() );
    3232
    3333        yield( ((unsigned)rand48()) % 10 );
    3434
    35         if(a->state != SIGNAL || b->state != SIGNAL) {
    36                 sout | "ERROR Barging detected" | a->state | b->state | endl;
     35        if(a->last_thread != a->last_signaller || b->last_thread != b->last_signaller ) {
     36                sout | "ERROR Barging detected, expected" | a->last_signaller | b->last_signaller | "got" | a->last_thread | b->last_thread | endl;
    3737                abort();
    3838        }
    3939
    40         a->state = b->state = WAITED;
     40        a->last_thread = b->last_thread = this_thread();
    4141
    4242        yield( ((unsigned)rand48()) % 10 );
     
    5454        yield( ((unsigned)rand48()) % 10 );
    5555
    56         a->ran = b->ran = false;
    57         a->state = b->state = SIGNAL;
     56        a->last_thread = b->last_thread = a->last_signaller = b->last_signaller = this_thread();
    5857
    59         signal_block( &cond );
     58        if( !is_empty( &cond ) ) {
    6059
    61         yield( ((unsigned)rand48()) % 10 );
     60                thread_desc * next = front( &cond );
    6261
    63         assert(a->ran == b->ran);
    64         if(a->ran)
    65         {
    66                 if(a->state != WAITED || b->state != WAITED) {
    67                         sout | "ERROR Barging detected" | a->state | b->state | endl;
     62                if( ! signal_block( &cond ) ) {
     63                        sout | "ERROR expected to be able to signal" | endl;
     64                        abort();
     65                }
     66
     67                yield( ((unsigned)rand48()) % 10 );
     68
     69                if(a->last_thread != next || b->last_thread != next) {
     70                        sout | "ERROR Barging detected, expected" | next | "got" | a->last_thread | b->last_thread | endl;
    6871                        abort();
    6972                }
     
    8184//------------------------------------------------------------------------------
    8285void barge_op( global_data_t * mutex a ) {
    83         a->state = BARGE;
     86        a->last_thread = this_thread();
    8487}
    8588
Note: See TracChangeset for help on using the changeset viewer.