Ignore:
File:
1 edited

Legend:

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

    re60e0dc rd6ff3ff  
    4747KERNEL_STORAGE(cluster, systemCluster);
    4848KERNEL_STORAGE(system_proc_t, systemProcessor);
    49 KERNEL_STORAGE(event_kernel_t, event_kernel);
    5049KERNEL_STORAGE(thread_desc, mainThread);
    5150KERNEL_STORAGE(machine_context_t, mainThreadCtx);
     
    5352cluster * systemCluster;
    5453system_proc_t * systemProcessor;
    55 event_kernel_t * event_kernel;
    5654thread_desc * mainThread;
    5755
     
    133131        this->cltr = cltr;
    134132        (&this->terminated){ 0 };
    135         this->do_terminate = false;
     133        this->is_terminated = false;
    136134        this->preemption_alarm = NULL;
     135        this->preemption = default_preemption();
    137136        this->pending_preemption = false;
    138137
     
    143142        this->cltr = cltr;
    144143        (&this->terminated){ 0 };
    145         this->do_terminate = false;
     144        this->is_terminated = false;
    146145        this->preemption_alarm = NULL;
     146        this->preemption = default_preemption();
    147147        this->pending_preemption = false;
    148148        this->kernel_thread = pthread_self();
     
    156156
    157157void ?{}(system_proc_t * this, cluster * cltr, processorCtx_t * runner) {
     158        (&this->alarms){};
     159        (&this->alarm_lock){};
     160        this->pending_alarm = false;
     161
    158162        (&this->proc){ cltr, runner };
    159 }
    160 
    161 void ?{}(event_kernel_t * this) {
    162         (&this->alarms){};
    163         (&this->lock){};
    164163
    165164        verify( validate( &this->alarms ) );
     
    167166
    168167void ^?{}(processor * this) {
    169         if( ! this->do_terminate ) {
     168        if( ! this->is_terminated ) {
    170169                LIB_DEBUG_PRINT_SAFE("Kernel : core %p signaling termination\n", this);
    171                 this->do_terminate = true;
     170                this->is_terminated = true;
    172171                P( &this->terminated );
    173172                pthread_join( this->kernel_thread, NULL );
     
    177176void ?{}(cluster * this) {
    178177        ( &this->ready_queue ){};
    179         ( &this->ready_queue_lock ){};
    180 
    181         this->preemption = default_preemption();
     178        ( &this->lock ){};
    182179}
    183180
     
    202199
    203200                thread_desc * readyThread = NULL;
    204                 for( unsigned int spin_count = 0; ! this->do_terminate; spin_count++ )
     201                for( unsigned int spin_count = 0; ! this->is_terminated; spin_count++ )
    205202                {
    206203                        readyThread = nextThread( this->cltr );
     
    346343        verifyf( thrd->next == NULL, "Expected null got %p", thrd->next );
    347344
    348         lock( &systemProcessor->proc.cltr->ready_queue_lock DEBUG_CTX2 );
     345        lock( &systemProcessor->proc.cltr->lock DEBUG_CTX2 );
    349346        append( &systemProcessor->proc.cltr->ready_queue, thrd );
    350         unlock( &systemProcessor->proc.cltr->ready_queue_lock );
     347        unlock( &systemProcessor->proc.cltr->lock );
    351348
    352349        verify( disable_preempt_count > 0 );
     
    355352thread_desc * nextThread(cluster * this) {
    356353        verify( disable_preempt_count > 0 );
    357         lock( &this->ready_queue_lock DEBUG_CTX2 );
     354        lock( &this->lock DEBUG_CTX2 );
    358355        thread_desc * head = pop_head( &this->ready_queue );
    359         unlock( &this->ready_queue_lock );
     356        unlock( &this->lock );
    360357        verify( disable_preempt_count > 0 );
    361358        return head;
     
    473470        systemProcessor{ systemCluster, (processorCtx_t *)&systemProcessorCtxStorage };
    474471
    475         // Initialize the event kernel
    476         event_kernel = (event_kernel_t *)&event_kernelStorage;
    477         event_kernel{};
    478 
    479472        // Add the main thread to the ready queue
    480473        // once resume is called on systemProcessor->runner the mainThread needs to be scheduled like any normal thread
     
    511504        // When its coroutine terminates, it return control to the mainThread
    512505        // which is currently here
    513         systemProcessor->proc.do_terminate = true;
     506        systemProcessor->proc.is_terminated = true;
    514507        suspend();
    515508
Note: See TracChangeset for help on using the changeset viewer.