Ignore:
Timestamp:
Apr 24, 2021, 7:03:47 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:
734908c
Parents:
c6c7e6c
Message:

Changed enable interrupts:

  • no longer save the caller for debugging
  • now polls based on parameter passed in
File:
1 edited

Legend:

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

    rc6c7e6c ra3821fa  
    126126extern void __disable_interrupts_hard();
    127127extern void __enable_interrupts_hard();
     128
     129static inline void __disable_interrupts_checked() {
     130        /* paranoid */ verify( __preemption_enabled() );
     131        disable_interrupts();
     132        /* paranoid */ verify( ! __preemption_enabled() );
     133}
     134
     135static inline void __enable_interrupts_checked( bool poll = true ) {
     136        /* paranoid */ verify( ! __preemption_enabled() );
     137        enable_interrupts( poll );
     138        /* paranoid */ verify( __preemption_enabled() );
     139}
    128140
    129141//=============================================================================================
     
    517529
    518530        if(__must_unpark(thrd)) {
    519                 /* paranoid */ verify( publicTLS_get(this_proc_id) );
    520531                disable_interrupts();
    521 
    522                 /* paranoid */ verify( ! __preemption_enabled() );
    523 
    524                 // Wake lost the race,
    525                 __schedule_thread( thrd );
    526 
    527                 /* paranoid */ verify( ! __preemption_enabled() );
    528 
    529                 enable_interrupts_noPoll();
    530                 /* paranoid */ verify( publicTLS_get(this_proc_id) );
     532                        // Wake lost the race,
     533                        __schedule_thread( thrd );
     534                enable_interrupts(false);
    531535        }
    532536}
    533537
    534538void park( void ) {
    535         /* paranoid */ verify( __preemption_enabled() );
    536         disable_interrupts();
    537         /* paranoid */ verify( ! __preemption_enabled() );
    538         /* paranoid */ verify( kernelTLS().this_thread->preempted == __NO_PREEMPTION );
    539 
    540         returnToKernel();
    541 
    542         /* paranoid */ verify( ! __preemption_enabled() );
    543         enable_interrupts( __cfaabi_dbg_ctx );
    544         /* paranoid */ verify( __preemption_enabled() );
     539        __disable_interrupts_checked();
     540                /* paranoid */ verify( kernelTLS().this_thread->preempted == __NO_PREEMPTION );
     541                returnToKernel();
     542        __enable_interrupts_checked();
    545543
    546544}
     
    582580// KERNEL ONLY
    583581bool force_yield( __Preemption_Reason reason ) {
    584         /* paranoid */ verify( __preemption_enabled() );
    585         disable_interrupts();
    586         /* paranoid */ verify( ! __preemption_enabled() );
    587 
    588         $thread * thrd = kernelTLS().this_thread;
    589         /* paranoid */ verify(thrd->state == Active);
    590 
    591         // SKULLDUGGERY: It is possible that we are preempting this thread just before
    592         // it was going to park itself. If that is the case and it is already using the
    593         // intrusive fields then we can't use them to preempt the thread
    594         // If that is the case, abandon the preemption.
    595         bool preempted = false;
    596         if(thrd->link.next == 0p) {
    597                 preempted = true;
    598                 thrd->preempted = reason;
    599                 returnToKernel();
    600         }
    601 
    602         /* paranoid */ verify( ! __preemption_enabled() );
    603         enable_interrupts_noPoll();
    604         /* paranoid */ verify( __preemption_enabled() );
    605 
     582        __disable_interrupts_checked();
     583                $thread * thrd = kernelTLS().this_thread;
     584                /* paranoid */ verify(thrd->state == Active);
     585
     586                // SKULLDUGGERY: It is possible that we are preempting this thread just before
     587                // it was going to park itself. If that is the case and it is already using the
     588                // intrusive fields then we can't use them to preempt the thread
     589                // If that is the case, abandon the preemption.
     590                bool preempted = false;
     591                if(thrd->link.next == 0p) {
     592                        preempted = true;
     593                        thrd->preempted = reason;
     594                        returnToKernel();
     595                }
     596        __enable_interrupts_checked( false );
    606597        return preempted;
    607598}
     
    648639        __cfadbg_print_safe(runtime_core, "Kernel : waking Processor %p\n", this);
    649640
    650         disable_interrupts();
     641        __disable_interrupts_checked();
    651642                /* paranoid */ verify( ! __preemption_enabled() );
    652643                eventfd_t val;
    653644                val = 1;
    654645                eventfd_write( this->idle, val );
    655         enable_interrupts( __cfaabi_dbg_ctx );
     646        __enable_interrupts_checked();
    656647}
    657648
Note: See TracChangeset for help on using the changeset viewer.