Ignore:
File:
1 edited

Legend:

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

    rde94a60 rb10affd  
    3030//-----------------------------------------------------------------------------
    3131// Thread ctors and dtors
    32 void ?{}(thread_desc & this, const char * const name, cluster & cl, void * storage, size_t storageSize ) with( this ) {
    33         self_cor{ name, storage, storageSize };
    34         verify(&self_cor);
     32
     33void ?{}(thread_desc& this) with( this ) {
     34        self_cor{};
     35        self_cor.name = "Anonymous Coroutine";
    3536        curr_cor = &self_cor;
    3637        self_mon.owner = &this;
    3738        self_mon.recursion = 1;
    3839        self_mon_p = &self_mon;
    39         curr_cluster = &cl;
    4040        next = NULL;
    41 
    42         node.next = NULL;
    43         node.prev = NULL;
    44         doregister(this);
     41        __cfaabi_dbg_debug_do(
     42                dbg_next = NULL;
     43                dbg_prev = NULL;
     44                __cfaabi_dbg_thread_register(&this);
     45        )
    4546
    4647        monitors{ &self_mon_p, 1, (fptr_t)0 };
     
    4849
    4950void ^?{}(thread_desc& this) with( this ) {
    50         unregister(this);
    5151        ^self_cor{};
    5252}
     
    8181        disable_interrupts();
    8282        create_stack(&thrd_c->stack, thrd_c->stack.size);
    83         kernelTLS.this_coroutine = thrd_c;
     83        TL_SET( this_coroutine, thrd_c );
    8484        CtxStart(&this, CtxInvokeThread);
    8585        assert( thrd_c->last->stack.context );
     
    9191
    9292extern "C" {
    93         // KERNEL ONLY
    9493        void __finish_creation(void) {
    95                 coroutine_desc* thrd_c = kernelTLS.this_coroutine;
     94                coroutine_desc* thrd_c = TL_GET( this_coroutine );
    9695                ThreadCtxSwitch( thrd_c, thrd_c->last );
    9796        }
     
    9998
    10099void yield( void ) {
    101         // Safety note : This could cause some false positives due to preemption
    102       verify( TL_GET( preemption_state.enabled ) );
     100        verify( TL_GET( preemption_state ).enabled );
    103101        BlockInternal( TL_GET( this_thread ) );
    104         // Safety note : This could cause some false positives due to preemption
    105       verify( TL_GET( preemption_state.enabled ) );
     102        verify( TL_GET( preemption_state ).enabled );
    106103}
    107104
     
    112109}
    113110
    114 // KERNEL ONLY
    115111void ThreadCtxSwitch(coroutine_desc* src, coroutine_desc* dst) {
    116112        // set state of current coroutine to inactive
     
    120116        // set new coroutine that the processor is executing
    121117        // and context switch to it
    122         kernelTLS.this_coroutine = dst;
     118        TL_SET( this_coroutine, dst );
    123119        assert( src->stack.context );
    124120        CtxSwitch( src->stack.context, dst->stack.context );
    125         kernelTLS.this_coroutine = src;
     121        TL_SET( this_coroutine, src );
    126122
    127123        // set state of new coroutine to active
Note: See TracChangeset for help on using the changeset viewer.