Ignore:
File:
1 edited

Legend:

Unmodified
Added
Removed
  • libcfa/src/concurrency/kernel.cfa

    r58d64a4 rb4b63e8  
    246246                thrd_dst->state = Active;
    247247
    248                 __cfaabi_dbg_debug_do(
    249                         thrd_dst->park_stale   = true;
    250                         thrd_dst->unpark_stale = true;
    251                 )
    252248                // Update global state
    253249                kernelTLS.this_thread = thrd_dst;
     
    255251                /* paranoid */ verify( ! kernelTLS.preemption_state.enabled );
    256252                /* paranoid */ verify( kernelTLS.this_thread == thrd_dst );
     253                /* paranoid */ verify( thrd_dst->context.SP );
    257254                /* paranoid */ verifyf( ((uintptr_t)thrd_dst->context.SP) < ((uintptr_t)__get_stack(thrd_dst->curr_cor)->base ) || thrd_dst->curr_cor == proc_cor, "ERROR : Destination $thread %p has been corrupted.\n StackPointer too small.\n", thrd_dst ); // add escape condition if we are setting up the processor
    258255                /* paranoid */ verifyf( ((uintptr_t)thrd_dst->context.SP) > ((uintptr_t)__get_stack(thrd_dst->curr_cor)->limit) || thrd_dst->curr_cor == proc_cor, "ERROR : Destination $thread %p has been corrupted.\n StackPointer too large.\n", thrd_dst ); // add escape condition if we are setting up the processor
     256                /* paranoid */ verify( 0x0D15EA5E0D15EA5E == thrd_dst->canary );
     257
    259258
    260259
    261260                // set context switch to the thread that the processor is executing
    262                 verify( thrd_dst->context.SP );
    263261                __cfactx_switch( &proc_cor->context, &thrd_dst->context );
    264262                // when __cfactx_switch returns we are back in the processor coroutine
    265263
     264                /* paranoid */ verify( 0x0D15EA5E0D15EA5E == thrd_dst->canary );
    266265                /* paranoid */ verifyf( ((uintptr_t)thrd_dst->context.SP) > ((uintptr_t)__get_stack(thrd_dst->curr_cor)->limit), "ERROR : Destination $thread %p has been corrupted.\n StackPointer too large.\n", thrd_dst );
    267266                /* paranoid */ verifyf( ((uintptr_t)thrd_dst->context.SP) < ((uintptr_t)__get_stack(thrd_dst->curr_cor)->base ), "ERROR : Destination $thread %p has been corrupted.\n StackPointer too small.\n", thrd_dst );
     267                /* paranoid */ verify( thrd_dst->context.SP );
    268268                /* paranoid */ verify( kernelTLS.this_thread == thrd_dst );
    269269                /* paranoid */ verify( ! kernelTLS.preemption_state.enabled );
     
    288288                        // The thread has halted, it should never be scheduled/run again
    289289                        // We may need to wake someone up here since
    290                         unpark( this->destroyer __cfaabi_dbg_ctx2 );
     290                        unpark( this->destroyer );
    291291                        this->destroyer = 0p;
    292292                        break RUNNING;
     
    298298                // set state of processor coroutine to active and the thread to inactive
    299299                int old_ticket = __atomic_fetch_sub(&thrd_dst->ticket, 1, __ATOMIC_SEQ_CST);
    300                 __cfaabi_dbg_debug_do( thrd_dst->park_result = old_ticket; )
    301300                switch(old_ticket) {
    302301                        case 1:
     
    335334                        __x87_store;
    336335                #endif
    337                 verify( proc_cor->context.SP );
     336                /* paranoid */ verify( proc_cor->context.SP );
     337                /* paranoid */ verify( 0x0D15EA5E0D15EA5E == thrd_src->canary );
    338338                __cfactx_switch( &thrd_src->context, &proc_cor->context );
     339                /* paranoid */ verify( 0x0D15EA5E0D15EA5E == thrd_src->canary );
    339340                #if defined( __i386 ) || defined( __x86_64 )
    340341                        __x87_load;
     
    368369        /* paranoid */ #endif
    369370        /* paranoid */ verifyf( thrd->link.next == 0p, "Expected null got %p", thrd->link.next );
     371        /* paranoid */ verify( 0x0D15EA5E0D15EA5E == thrd->canary );
     372
    370373
    371374        if (thrd->preempted == __NO_PREEMPTION) thrd->state = Ready;
     
    404407
    405408// KERNEL ONLY unpark with out disabling interrupts
    406 void __unpark(  struct __processor_id_t * id, $thread * thrd __cfaabi_dbg_ctx_param2 ) {
    407         // record activity
    408         __cfaabi_dbg_record_thrd( *thrd, false, caller );
    409 
     409void __unpark(  struct __processor_id_t * id, $thread * thrd ) {
    410410        int old_ticket = __atomic_fetch_add(&thrd->ticket, 1, __ATOMIC_SEQ_CST);
    411         __cfaabi_dbg_debug_do( thrd->unpark_result = old_ticket; thrd->unpark_state = thrd->state; )
    412411        switch(old_ticket) {
    413412                case 1:
     
    427426}
    428427
    429 void unpark( $thread * thrd __cfaabi_dbg_ctx_param2 ) {
     428void unpark( $thread * thrd ) {
    430429        if( !thrd ) return;
    431430
    432431        disable_interrupts();
    433         __unpark( (__processor_id_t*)kernelTLS.this_processor, thrd __cfaabi_dbg_ctx_fwd2 );
     432        __unpark( (__processor_id_t*)kernelTLS.this_processor, thrd );
    434433        enable_interrupts( __cfaabi_dbg_ctx );
    435434}
    436435
    437 void park( __cfaabi_dbg_ctx_param ) {
     436void park( void ) {
    438437        /* paranoid */ verify( kernelTLS.preemption_state.enabled );
    439438        disable_interrupts();
    440439        /* paranoid */ verify( ! kernelTLS.preemption_state.enabled );
    441440        /* paranoid */ verify( kernelTLS.this_thread->preempted == __NO_PREEMPTION );
    442 
    443         // record activity
    444         __cfaabi_dbg_record_thrd( *kernelTLS.this_thread, true, caller );
    445441
    446442        returnToKernel();
     
    650646                // atomically release spin lock and block
    651647                unlock( lock );
    652                 park( __cfaabi_dbg_ctx );
     648                park();
    653649                return true;
    654650        }
     
    671667
    672668        // make new owner
    673         unpark( thrd __cfaabi_dbg_ctx2 );
     669        unpark( thrd );
    674670
    675671        return thrd != 0p;
     
    682678        count += diff;
    683679        for(release) {
    684                 unpark( pop_head( waiting ) __cfaabi_dbg_ctx2 );
     680                unpark( pop_head( waiting ) );
    685681        }
    686682
     
    698694                        this.prev_thrd = kernelTLS.this_thread;
    699695                }
    700 
    701                 void __cfaabi_dbg_record_thrd($thread & this, bool park, const char prev_name[]) {
    702                         if(park) {
    703                                 this.park_caller   = prev_name;
    704                                 this.park_stale    = false;
    705                         }
    706                         else {
    707                                 this.unpark_caller = prev_name;
    708                                 this.unpark_stale  = false;
    709                         }
    710                 }
    711696        }
    712697)
Note: See TracChangeset for help on using the changeset viewer.