Changeset 254ad1b for libcfa


Ignore:
Timestamp:
Apr 24, 2021, 7:24:09 PM (3 years ago)
Author:
Thierry Delisle <tdelisle@…>
Branches:
ADT, arm-eh, ast-experimental, enum, forall-pointer-decay, jacob/cs343-translation, master, new-ast-unique-expr, pthread-emulation, qualifiedEnum
Children:
a76efc8, cfff639
Parents:
734908c
Message:

Separate schedule_thread from the scheduler lock

Location:
libcfa/src/concurrency
Files:
4 edited

Legend:

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

    r734908c r254ad1b  
    349349                if(unlikely(thrd_dst->preempted != __NO_PREEMPTION)) {
    350350                        // The thread was preempted, reschedule it and reset the flag
    351                         __schedule_thread( thrd_dst );
     351                        schedule_thread$( thrd_dst );
    352352                        break RUNNING;
    353353                }
     
    439439        /* paranoid */ verify( ! __preemption_enabled() );
    440440        /* paranoid */ verify( kernelTLS().this_proc_id );
     441        /* paranoid */ verify( ready_schedule_islocked());
    441442        /* paranoid */ verify( thrd );
    442443        /* paranoid */ verify( thrd->state != Halted );
     
    457458        struct cluster * cl = thrd->curr_cluster;
    458459
    459         ready_schedule_lock();
    460                 // push the thread to the cluster ready-queue
    461                 push( cl, thrd );
    462 
    463                 // variable thrd is no longer safe to use
     460        // push the thread to the cluster ready-queue
     461        push( cl, thrd );
     462
     463        // variable thrd is no longer safe to use
    464464        thrd = 0xdeaddeaddeaddeadp;
    465465
    466                 // wake the cluster using the save variable.
    467                 __wake_one( cl );
    468         ready_schedule_unlock();
     466        // wake the cluster using the save variable.
     467        __wake_one( cl );
    469468
    470469        #if !defined(__CFA_NO_STATISTICS__)
     
    479478        #endif
    480479
    481         /* paranoid */ verify( ! __preemption_enabled() );
     480        /* paranoid */ verify( ready_schedule_islocked());
     481        /* paranoid */ verify( ! __preemption_enabled() );
     482}
     483
     484void schedule_thread$( $thread * thrd ) {
     485        ready_schedule_lock();
     486                __schedule_thread( thrd );
     487        ready_schedule_unlock();
    482488}
    483489
     
    532538                disable_interrupts();
    533539                        // Wake lost the race,
    534                         __schedule_thread( thrd );
     540                        schedule_thread$( thrd );
    535541                enable_interrupts(false);
    536542        }
  • libcfa/src/concurrency/kernel/startup.cfa

    r734908c r254ad1b  
    225225        // Add the main thread to the ready queue
    226226        // once resume is called on mainProcessor->runner the mainThread needs to be scheduled like any normal thread
    227         __schedule_thread(mainThread);
     227        schedule_thread$(mainThread);
    228228
    229229        // SKULLDUGGERY: Force a context switch to the main processor to set the main thread's context to the current UNIX
  • libcfa/src/concurrency/kernel_private.hfa

    r734908c r254ad1b  
    3232}
    3333
    34 void __schedule_thread( $thread * )
    35 #if defined(NDEBUG) || (!defined(__CFA_DEBUG__) && !defined(__CFA_VERIFY__))
    36         __attribute__((nonnull (1)))
    37 #endif
    38 ;
     34void schedule_thread$( $thread * ) __attribute__((nonnull (1)));
    3935
    4036extern bool __preemption_enabled();
  • libcfa/src/concurrency/thread.cfa

    r734908c r254ad1b  
    134134        /* paranoid */ verify( this_thrd->context.SP );
    135135
    136         __schedule_thread( this_thrd );
     136        schedule_thread$( this_thrd );
    137137        enable_interrupts();
    138138}
Note: See TracChangeset for help on using the changeset viewer.