- File:
-
- 1 edited
Legend:
- Unmodified
- Added
- Removed
-
libcfa/src/concurrency/preemption.cfa
ra33c113 ra3821fa 315 315 // Enable interrupts by decrementing the counter 316 316 // If counter reaches 0, execute any pending __cfactx_switch 317 void enable_interrupts( __cfaabi_dbg_ctx_param) {317 void enable_interrupts( bool poll ) { 318 318 // Cache the processor now since interrupts can start happening after the atomic store 319 319 processor * proc = __cfaabi_tls.this_processor; 320 /* paranoid */ verify( proc );320 /* paranoid */ verify( !poll || proc ); 321 321 322 322 with( __cfaabi_tls.preemption_state ){ … … 340 340 // Signal the compiler that a fence is needed but only for signal handlers 341 341 __atomic_signal_fence(__ATOMIC_RELEASE); 342 if( p roc->pending_preemption ) {342 if( poll && proc->pending_preemption ) { 343 343 proc->pending_preemption = false; 344 344 force_yield( __POLL_PREEMPTION ); 345 345 } 346 346 } 347 }348 349 // For debugging purposes : keep track of the last person to enable the interrupts350 __cfaabi_dbg_debug_do( proc->last_enable = caller; )351 }352 353 // Disable interrupts by incrementint the counter354 // Don't execute any pending __cfactx_switch even if counter reaches 0355 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 interrupts359 /* paranoid */ verifyf( prev != 0u, "Incremented from %u\n", prev );360 if( prev == 1 ) {361 #if GCC_VERSION > 50000362 static_assert(__atomic_always_lock_free(sizeof(__cfaabi_tls.preemption_state.enabled), &__cfaabi_tls.preemption_state.enabled), "Must be lock-free");363 #endif364 // Set enabled flag to true365 // 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 requirements367 __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 handlers370 __atomic_signal_fence(__ATOMIC_RELEASE);371 347 } 372 348 }
Note: See TracChangeset
for help on using the changeset viewer.