Ignore:
File:
1 edited

Legend:

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

    rb69ea6b rd8548e2  
    6060// volatile thread_local unsigned short disable_preempt_count = 1;
    6161
    62 volatile thread_local __cfa_kernel_preemption_data_t preemption = { false, false, 1 };
     62volatile thread_local __cfa_kernel_preemption_state_t preemption_state = { false, false, 1 };
    6363
    6464//-----------------------------------------------------------------------------
     
    180180        ready_queue_lock{};
    181181
    182         preemption = default_preemption();
     182        preemption_rate = default_preemption();
    183183}
    184184
     
    209209                        if(readyThread)
    210210                        {
    211                                 verify( !preemption.enabled );
     211                                verify( !preemption_state.enabled );
    212212
    213213                                runThread(this, readyThread);
    214214
    215                                 verify( !preemption.enabled );
     215                                verify( !preemption_state.enabled );
    216216
    217217                                //Some actions need to be taken from the kernel
     
    262262void finishRunning(processor * this) with( this->finish ) {
    263263        if( action_code == Release ) {
    264                 verify( !preemption.enabled );
     264                verify( !preemption_state.enabled );
    265265                unlock( *lock );
    266266        }
     
    269269        }
    270270        else if( action_code == Release_Schedule ) {
    271                 verify( !preemption.enabled );
     271                verify( !preemption_state.enabled );
    272272                unlock( *lock );
    273273                ScheduleThread( thrd );
    274274        }
    275275        else if( action_code == Release_Multi ) {
    276                 verify( !preemption.enabled );
     276                verify( !preemption_state.enabled );
    277277                for(int i = 0; i < lock_count; i++) {
    278278                        unlock( *locks[i] );
     
    306306        this_coroutine = NULL;
    307307        this_thread = NULL;
    308         preemption.enabled = false;
    309         preemption.disable_count = 1;
     308        preemption_state.enabled = false;
     309        preemption_state.disable_count = 1;
    310310        // SKULLDUGGERY: We want to create a context for the processor coroutine
    311311        // which is needed for the 2-step context switch. However, there is no reason
     
    351351        coroutine_desc * dst = get_coroutine(*this->runner);
    352352
    353         verify( !preemption.enabled );
     353        verify( !preemption_state.enabled );
    354354
    355355        create_stack(&dst->stack, dst->stack.size);
    356356        CtxStart(this->runner, CtxInvokeCoroutine);
    357357
    358         verify( !preemption.enabled );
     358        verify( !preemption_state.enabled );
    359359
    360360        dst->last = src;
     
    382382        src->state = Active;
    383383
    384         verify( !preemption.enabled );
     384        verify( !preemption_state.enabled );
    385385}
    386386
     
    392392        verify( thrd->self_cor.state != Halted );
    393393
    394         verify( !preemption.enabled );
     394        verify( !preemption_state.enabled );
    395395
    396396        verifyf( thrd->next == NULL, "Expected null got %p", thrd->next );
     
    402402        }
    403403
    404         verify( !preemption.enabled );
     404        verify( !preemption_state.enabled );
    405405}
    406406
    407407thread_desc * nextThread(cluster * this) with( *this ) {
    408         verify( !preemption.enabled );
     408        verify( !preemption_state.enabled );
    409409        lock( ready_queue_lock __cfaabi_dbg_ctx2 );
    410410        thread_desc * head = pop_head( ready_queue );
    411411        unlock( ready_queue_lock );
    412         verify( !preemption.enabled );
     412        verify( !preemption_state.enabled );
    413413        return head;
    414414}
     
    416416void BlockInternal() {
    417417        disable_interrupts();
    418         verify( !preemption.enabled );
     418        verify( !preemption_state.enabled );
    419419        returnToKernel();
    420         verify( !preemption.enabled );
     420        verify( !preemption_state.enabled );
    421421        enable_interrupts( __cfaabi_dbg_ctx );
    422422}
     
    427427        this_processor->finish.lock        = lock;
    428428
    429         verify( !preemption.enabled );
     429        verify( !preemption_state.enabled );
    430430        returnToKernel();
    431         verify( !preemption.enabled );
     431        verify( !preemption_state.enabled );
    432432
    433433        enable_interrupts( __cfaabi_dbg_ctx );
     
    439439        this_processor->finish.thrd        = thrd;
    440440
    441         verify( !preemption.enabled );
     441        verify( !preemption_state.enabled );
    442442        returnToKernel();
    443         verify( !preemption.enabled );
     443        verify( !preemption_state.enabled );
    444444
    445445        enable_interrupts( __cfaabi_dbg_ctx );
     
    453453        this_processor->finish.thrd        = thrd;
    454454
    455         verify( !preemption.enabled );
     455        verify( !preemption_state.enabled );
    456456        returnToKernel();
    457         verify( !preemption.enabled );
     457        verify( !preemption_state.enabled );
    458458
    459459        enable_interrupts( __cfaabi_dbg_ctx );
     
    466466        this_processor->finish.lock_count  = count;
    467467
    468         verify( !preemption.enabled );
     468        verify( !preemption_state.enabled );
    469469        returnToKernel();
    470         verify( !preemption.enabled );
     470        verify( !preemption_state.enabled );
    471471
    472472        enable_interrupts( __cfaabi_dbg_ctx );
     
    481481        this_processor->finish.thrd_count  = thrd_count;
    482482
    483         verify( !preemption.enabled );
     483        verify( !preemption_state.enabled );
    484484        returnToKernel();
    485         verify( !preemption.enabled );
     485        verify( !preemption_state.enabled );
    486486
    487487        enable_interrupts( __cfaabi_dbg_ctx );
     
    489489
    490490void LeaveThread(__spinlock_t * lock, thread_desc * thrd) {
    491         verify( !preemption.enabled );
     491        verify( !preemption_state.enabled );
    492492        this_processor->finish.action_code = thrd ? Release_Schedule : Release;
    493493        this_processor->finish.lock        = lock;
     
    503503// Kernel boot procedures
    504504void kernel_startup(void) {
    505         verify( !preemption.enabled );
     505        verify( !preemption_state.enabled );
    506506        __cfaabi_dbg_print_safe("Kernel : Starting\n");
    507507
     
    548548        __cfaabi_dbg_print_safe("Kernel : Started\n--------------------------------------------------\n\n");
    549549
    550         verify( !preemption.enabled );
     550        verify( !preemption_state.enabled );
    551551        enable_interrupts( __cfaabi_dbg_ctx );
    552         verify( preemption.enabled );
     552        verify( preemption_state.enabled );
    553553}
    554554
     
    556556        __cfaabi_dbg_print_safe("\n--------------------------------------------------\nKernel : Shutting down\n");
    557557
    558         verify( preemption.enabled );
     558        verify( preemption_state.enabled );
    559559        disable_interrupts();
    560         verify( !preemption.enabled );
     560        verify( !preemption_state.enabled );
    561561
    562562        // SKULLDUGGERY: Notify the mainProcessor it needs to terminates.
Note: See TracChangeset for help on using the changeset viewer.