Ignore:
Timestamp:
Jun 12, 2020, 1:49:17 PM (4 years ago)
Author:
Thierry Delisle <tdelisle@…>
Branches:
ADT, arm-eh, ast-experimental, enum, forall-pointer-decay, jacob/cs343-translation, master, new-ast, new-ast-unique-expr, pthread-emulation, qualifiedEnum
Children:
cb196f2
Parents:
b388ee81
Message:

Changed scheduling API to adapt to non-Processors scheduling threads.

File:
1 edited

Legend:

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

    rb388ee81 r9b1dcc2  
    300300        // register the processor unless it's the main thread which is handled in the boot sequence
    301301        if(this != mainProcessor) {
    302                 this->id = doregister(this);
     302                this->id = doregister((__processor_id_t*)this);
    303303                ready_queue_grow( this->cltr );
    304304        }
     
    346346        if(this != mainProcessor) {
    347347                ready_queue_shrink( this->cltr );
    348                 unregister(this);
     348                unregister((__processor_id_t*)this);
    349349        }
    350350        else {
     
    416416                if(unlikely(thrd_dst->preempted != __NO_PREEMPTION)) {
    417417                        // The thread was preempted, reschedule it and reset the flag
    418                         __schedule_thread( thrd_dst );
     418                        __schedule_thread( (__processor_id_t*)this, thrd_dst );
    419419                        break RUNNING;
    420420                }
     
    609609// Scheduler routines
    610610// KERNEL ONLY
    611 void __schedule_thread( $thread * thrd ) {
     611void __schedule_thread( struct __processor_id_t * id, $thread * thrd ) {
    612612        /* paranoid */ verify( thrd );
    613613        /* paranoid */ verify( thrd->state != Halted );
     
    623623        if (thrd->preempted == __NO_PREEMPTION) thrd->state = Ready;
    624624
    625         ready_schedule_lock( kernelTLS.this_processor );
     625        ready_schedule_lock  ( id );
    626626                push( thrd->curr_cluster, thrd );
    627627
    628628                __wake_one(thrd->curr_cluster);
    629         ready_schedule_unlock( kernelTLS.this_processor );
     629        ready_schedule_unlock( id );
    630630
    631631        /* paranoid */ verify( ! kernelTLS.preemption_state.enabled );
     
    636636        /* paranoid */ verify( ! kernelTLS.preemption_state.enabled );
    637637
    638         ready_schedule_lock( kernelTLS.this_processor );
     638        ready_schedule_lock  ( (__processor_id_t*)kernelTLS.this_processor );
    639639                $thread * head = pop( this );
    640         ready_schedule_unlock( kernelTLS.this_processor );
     640        ready_schedule_unlock( (__processor_id_t*)kernelTLS.this_processor );
    641641
    642642        /* paranoid */ verify( ! kernelTLS.preemption_state.enabled );
     
    645645
    646646// KERNEL ONLY unpark with out disabling interrupts
    647 void __unpark( $thread * thrd __cfaabi_dbg_ctx_param2 ) {
     647void __unpark(  struct __processor_id_t * id, $thread * thrd __cfaabi_dbg_ctx_param2 ) {
    648648        static_assert(sizeof(thrd->state) == sizeof(int));
    649649
     
    663663                        // Wake lost the race,
    664664                        thrd->state = Blocked;
    665                         __schedule_thread( thrd );
     665                        __schedule_thread( id, thrd );
    666666                        break;
    667667                case Rerun:
     
    681681
    682682        disable_interrupts();
    683         __unpark( thrd __cfaabi_dbg_ctx_fwd2 );
     683        __unpark( (__processor_id_t*)kernelTLS.this_processor, thrd __cfaabi_dbg_ctx_fwd2 );
    684684        enable_interrupts( __cfaabi_dbg_ctx );
    685685}
     
    798798        (*mainProcessor){};
    799799
    800         mainProcessor->id = doregister(mainProcessor);
     800        mainProcessor->id = doregister( (__processor_id_t*)mainProcessor);
    801801
    802802        //initialize the global state variables
     
    809809        // Add the main thread to the ready queue
    810810        // once resume is called on mainProcessor->runner the mainThread needs to be scheduled like any normal thread
    811         __schedule_thread(mainThread);
     811        __schedule_thread((__processor_id_t *)mainProcessor, mainThread);
    812812
    813813        // SKULLDUGGERY: Force a context switch to the main processor to set the main thread's context to the current UNIX
     
    853853        kernel_stop_preemption();
    854854
    855         unregister(mainProcessor);
     855        unregister((__processor_id_t*)mainProcessor);
    856856
    857857        // Destroy the main processor and its context in reverse order of construction
Note: See TracChangeset for help on using the changeset viewer.