- File:
-
- 1 edited
-
libcfa/src/concurrency/preemption.cfa (modified) (2 diffs)
Legend:
- Unmodified
- Added
- Removed
-
libcfa/src/concurrency/preemption.cfa
ra3821fa ra33c113 315 315 // Enable interrupts by decrementing the counter 316 316 // If counter reaches 0, execute any pending __cfactx_switch 317 void enable_interrupts( bool poll) {317 void enable_interrupts( __cfaabi_dbg_ctx_param ) { 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( !poll ||proc );320 /* paranoid */ verify( 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 oll && proc->pending_preemption ) {342 if( 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 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); 347 371 } 348 372 }
Note:
See TracChangeset
for help on using the changeset viewer.