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

File:
1 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        }
Note: See TracChangeset for help on using the changeset viewer.