Ignore:
File:
1 edited

Legend:

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

    r1757f98 r145dcd5  
    3434#include "kernel_private.hfa"
    3535#include "startup.hfa"          // STARTUP_PRIORITY_XXX
     36#include "limits.hfa"
    3637#include "math.hfa"
    3738
     
    279280        // When its coroutine terminates, it return control to the mainThread
    280281        // which is currently here
     282        /* paranoid */ verify( !__atomic_load_n(&mainProcessor->do_terminate, __ATOMIC_ACQUIRE) );
    281283        __atomic_store_n(&mainProcessor->do_terminate, true, __ATOMIC_RELEASE);
     284        __wake_proc( mainProcessor );
    282285        __kernel_last_resume( __cfaabi_tls.this_processor );
    283286        mainThread->self_cor.state = Halted;
     
    403406
    404407        __cfaabi_tls.this_thread->curr_cor = dst;
    405         __stack_prepare( &dst->stack, 65000 );
     408        __stack_prepare( &dst->stack, DEFAULT_STACK_SIZE );
    406409        __cfactx_start(main, dst, this->runner, __cfactx_invoke_coroutine);
    407410
     
    511514        this.rdq.its = 0;
    512515        this.rdq.itr = 0;
    513         this.rdq.id  = -1u;
    514         this.rdq.target = -1u;
    515         this.rdq.last = -1u;
    516         this.rdq.cutoff = 0ull;
     516        this.rdq.id  = MAX;
     517        this.rdq.target = MAX;
     518        this.rdq.last = MAX;
     519        this.rdq.cpu = 0;
     520        // this.rdq.cutoff = 0ull;
    517521        do_terminate = false;
    518522        preemption_alarm = 0p;
     
    564568extern size_t __page_size;
    565569void ^?{}(processor & this) with( this ){
    566         if( ! __atomic_load_n(&do_terminate, __ATOMIC_ACQUIRE) ) {
    567                 __cfadbg_print_safe(runtime_core, "Kernel : core %p signaling termination\n", &this);
    568 
    569                 __atomic_store_n(&do_terminate, true, __ATOMIC_RELAXED);
     570        /* paranoid */ verify( !__atomic_load_n(&do_terminate, __ATOMIC_ACQUIRE) );
     571        __cfadbg_print_safe(runtime_core, "Kernel : core %p signaling termination\n", &this);
     572
     573        __atomic_store_n(&do_terminate, true, __ATOMIC_RELAXED);
     574        __disable_interrupts_checked();
    570575                __wake_proc( &this );
    571 
    572                 wait( terminated );
    573                 /* paranoid */ verify( active_processor() != &this);
    574         }
     576        __enable_interrupts_checked();
     577
     578        wait( terminated );
     579        /* paranoid */ verify( active_processor() != &this);
    575580
    576581        __destroy_pthread( kernel_thread, this.stack, 0p );
     
    682687        [this->unique_id, last_size] = ready_mutate_register();
    683688
     689                this->rdq.cpu = __kernel_getcpu();
     690
    684691                this->cltr->procs.total += 1u;
    685692                insert_last(this->cltr->procs.actives, *this);
     
    721728        check( pthread_attr_init( &attr ), "pthread_attr_init" ); // initialize attribute
    722729
    723         size_t stacksize;
    724         // default stack size, normally defined by shell limit
    725         check( pthread_attr_getstacksize( &attr, &stacksize ), "pthread_attr_getstacksize" );
    726         assert( stacksize >= PTHREAD_STACK_MIN );
     730        size_t stacksize = DEFAULT_STACK_SIZE;
    727731
    728732        void * stack;
     
    749753        #endif
    750754
    751 
    752755        check( pthread_attr_setstack( &attr, stack, stacksize ), "pthread_attr_setstack" );
    753 
    754756        check( pthread_create( pthread, &attr, start, arg ), "pthread_create" );
    755757        return stack;
Note: See TracChangeset for help on using the changeset viewer.