Ignore:
Timestamp:
Apr 24, 2021, 7:45:02 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:
fb0be05
Parents:
89eff25 (diff), 254ad1b (diff)
Note: this is a merge changeset, the changes displayed below correspond to the merge itself.
Use the (diff) links above to see all the changes relative to each parent.
Message:

Merge branch 'master' of plg.uwaterloo.ca:software/cfa/cfa-cc

File:
1 edited

Legend:

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

    r89eff25 rcfff639  
    315315        // Enable interrupts by decrementing the counter
    316316        // If counter reaches 0, execute any pending __cfactx_switch
    317         void enable_interrupts( __cfaabi_dbg_ctx_param ) {
     317        void enable_interrupts( bool poll ) {
    318318                // Cache the processor now since interrupts can start happening after the atomic store
    319319                processor   * proc = __cfaabi_tls.this_processor;
    320                 /* paranoid */ verify( proc );
     320                /* paranoid */ verify( !poll || proc );
    321321
    322322                with( __cfaabi_tls.preemption_state ){
     
    340340                                // Signal the compiler that a fence is needed but only for signal handlers
    341341                                __atomic_signal_fence(__ATOMIC_RELEASE);
    342                                 if( proc->pending_preemption ) {
     342                                if( poll && proc->pending_preemption ) {
    343343                                        proc->pending_preemption = false;
    344344                                        force_yield( __POLL_PREEMPTION );
    345345                                }
    346346                        }
    347                 }
    348 
    349                 // For debugging purposes : keep track of the last person to enable the interrupts
    350                 __cfaabi_dbg_debug_do( proc->last_enable = caller; )
    351         }
    352 
    353         // Disable interrupts by incrementint the counter
    354         // Don't execute any pending __cfactx_switch even if counter reaches 0
    355         void enable_interrupts_noPoll() {
    356                 unsigned short prev = __cfaabi_tls.preemption_state.disable_count;
    357                 __cfaabi_tls.preemption_state.disable_count -= 1;
    358                 // If this triggers someone is enabled already enabled interrupts
    359                 /* paranoid */ verifyf( prev != 0u, "Incremented from %u\n", prev );
    360                 if( prev == 1 ) {
    361                         #if GCC_VERSION > 50000
    362                                 static_assert(__atomic_always_lock_free(sizeof(__cfaabi_tls.preemption_state.enabled), &__cfaabi_tls.preemption_state.enabled), "Must be lock-free");
    363                         #endif
    364                         // Set enabled flag to true
    365                         // should be atomic to avoid preemption in the middle of the operation.
    366                         // use memory order RELAXED since there is no inter-thread on this variable requirements
    367                         __atomic_store_n(&__cfaabi_tls.preemption_state.enabled, true, __ATOMIC_RELAXED);
    368 
    369                         // Signal the compiler that a fence is needed but only for signal handlers
    370                         __atomic_signal_fence(__ATOMIC_RELEASE);
    371347                }
    372348        }
Note: See TracChangeset for help on using the changeset viewer.