Ignore:
File:
1 edited

Legend:

Unmodified
Added
Removed
  • src/libcfa/concurrency/thread.c

    r2ac095d r44264c5  
    2828}
    2929
    30 extern volatile thread_local processor * this_processor;
     30extern thread_local processor * this_processor;
    3131
    3232//-----------------------------------------------------------------------------
     
    7171        coroutine_desc* thrd_c = get_coroutine(this);
    7272        thread_desc*  thrd_h = get_thread   (this);
    73         thrd_c->last = this_coroutine;
     73        thrd_c->last = this_coroutine();
     74        this_processor->current_coroutine = thrd_c;
    7475
    75         // LIB_DEBUG_PRINT_SAFE("Thread start : %p (t %p, c %p)\n", this, thrd_c, thrd_h);
     76        LIB_DEBUG_PRINT_SAFE("Thread start : %p (t %p, c %p)\n", this, thrd_c, thrd_h);
    7677
    77         disable_interrupts();
    7878        create_stack(&thrd_c->stack, thrd_c->stack.size);
    79         this_coroutine = thrd_c;
    8079        CtxStart(this, CtxInvokeThread);
    81         assert( thrd_c->last->stack.context );
    8280        CtxSwitch( thrd_c->last->stack.context, thrd_c->stack.context );
    8381
    8482        ScheduleThread(thrd_h);
    85         enable_interrupts( DEBUG_CTX );
    8683}
    8784
    8885void yield( void ) {
    89         BlockInternal( (thread_desc *)this_thread );
     86        ScheduleInternal( this_processor->current_thread );
    9087}
    9188
     
    9895void ThreadCtxSwitch(coroutine_desc* src, coroutine_desc* dst) {
    9996        // set state of current coroutine to inactive
    100         src->state = src->state == Halted ? Halted : Inactive;
     97        src->state = Inactive;
    10198        dst->state = Active;
    10299
     
    106103        // set new coroutine that the processor is executing
    107104        // and context switch to it
    108         this_coroutine = dst;
    109         assert( src->stack.context );
     105        this_processor->current_coroutine = dst;
    110106        CtxSwitch( src->stack.context, dst->stack.context );
    111         this_coroutine = src;
     107        this_processor->current_coroutine = src;
    112108
    113109        // set state of new coroutine to active
    114         dst->state = dst->state == Halted ? Halted : Inactive;
     110        dst->state = Inactive;
    115111        src->state = Active;
    116112}
Note: See TracChangeset for help on using the changeset viewer.