Ignore:
File:
1 edited

Legend:

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

    r5b2b42e rb798713  
    1010// Created On       : Tue Jan 17 12:27:26 2017
    1111// Last Modified By : Peter A. Buhr
    12 // Last Modified On : Wed Dec  4 09:17:49 2019
    13 // Update Count     : 9
     12// Last Modified On : Fri Mar 30 17:19:52 2018
     13// Update Count     : 8
    1414//
    1515
     
    3333// Thread ctors and dtors
    3434void ?{}(thread_desc & this, const char * const name, cluster & cl, void * storage, size_t storageSize ) with( this ) {
    35         context{ 0p, 0p };
     35        context{ NULL, NULL };
    3636        self_cor{ name, storage, storageSize };
    3737        state = Start;
     
    4141        self_mon_p = &self_mon;
    4242        curr_cluster = &cl;
    43         next = 0p;
     43        link.next = 0p;
     44        link.prev = 0p;
    4445
    45         node.next = 0p;
    46         node.prev = 0p;
     46        node.next = NULL;
     47        node.prev = NULL;
    4748        doregister(curr_cluster, this);
    4849
     
    5859void ?{}( scoped(T)& this ) with( this ) {
    5960        handle{};
    60         __thrd_start(handle, main);
     61        __thrd_start(handle);
    6162}
    6263
     
    6465void ?{}( scoped(T)& this, P params ) with( this ) {
    6566        handle{ params };
    66         __thrd_start(handle, main);
     67        __thrd_start(handle);
    6768}
    6869
     
    7576// Starting and stopping threads
    7677forall( dtype T | is_thread(T) )
    77 void __thrd_start( T & this, void (*main_p)(T &) ) {
     78void __thrd_start( T& this ) {
    7879        thread_desc * this_thrd = get_thread(this);
     80        thread_desc * curr_thrd = TL_GET( this_thread );
    7981
    8082        disable_interrupts();
    81         CtxStart(main_p, get_coroutine(this), this, CtxInvokeThread);
    82 
     83        CtxStart(&this, CtxInvokeThread);
    8384        this_thrd->context.[SP, FP] = this_thrd->self_cor.context.[SP, FP];
    8485        verify( this_thrd->context.SP );
     86        CtxSwitch( &curr_thrd->context, &this_thrd->context );
    8587
    8688        ScheduleThread(this_thrd);
    8789        enable_interrupts( __cfaabi_dbg_ctx );
     90}
     91
     92extern "C" {
     93        // KERNEL ONLY
     94        void __finish_creation(thread_desc * this) {
     95                // set new coroutine that the processor is executing
     96                // and context switch to it
     97                verify( kernelTLS.this_thread != this );
     98                verify( kernelTLS.this_thread->context.SP );
     99                CtxSwitch( &this->context, &kernelTLS.this_thread->context );
     100        }
    88101}
    89102
Note: See TracChangeset for help on using the changeset viewer.