- File:
-
- 1 edited
-
src/libcfa/concurrency/preemption.c (modified) (3 diffs)
Legend:
- Unmodified
- Added
- Removed
-
src/libcfa/concurrency/preemption.c
rde6319f r8ad6533 149 149 // Disable interrupts by incrementing the counter 150 150 void disable_interrupts() { 151 with( TL_GET( preemption_state ) ) { 152 enabled = false; 153 __attribute__((unused)) unsigned short new_val = disable_count + 1; 154 disable_count = new_val; 155 verify( new_val < 65_000u ); // If this triggers someone is disabling interrupts without enabling them 156 } 151 TL_GET( preemption_state ).enabled = false; 152 __attribute__((unused)) unsigned short new_val = TL_GET( preemption_state ).disable_count + 1; 153 TL_GET( preemption_state ).disable_count = new_val; 154 verify( new_val < 65_000u ); // If this triggers someone is disabling interrupts without enabling them 157 155 } 158 156 … … 163 161 thread_desc * thrd = TL_GET( this_thread ); // Cache the thread now since interrupts can start happening after the atomic add 164 162 165 with( TL_GET( preemption_state ) ){ 166 unsigned short prev = disable_count; 167 disable_count -= 1; 168 verify( prev != 0u ); // If this triggers someone is enabled already enabled interruptsverify( prev != 0u ); 169 170 // Check if we need to prempt the thread because an interrupt was missed 171 if( prev == 1 ) { 172 enabled = true; 173 if( proc->pending_preemption ) { 174 proc->pending_preemption = false; 175 BlockInternal( thrd ); 176 } 163 unsigned short prev = TL_GET( preemption_state ).disable_count; 164 TL_GET( preemption_state ).disable_count -= 1; 165 verify( prev != 0u ); // If this triggers someone is enabled already enabled interruptsverify( prev != 0u ); 166 167 // Check if we need to prempt the thread because an interrupt was missed 168 if( prev == 1 ) { 169 TL_GET( preemption_state ).enabled = true; 170 if( proc->pending_preemption ) { 171 proc->pending_preemption = false; 172 BlockInternal( thrd ); 177 173 } 178 174 } … … 332 328 if( !preemption_ready() ) { return; } 333 329 334 __cfaabi_dbg_print_buffer_decl( " KERNEL: preempting core %p (%p).\n", TL_GET( this_processor ), TL_GET( this_thread ));330 __cfaabi_dbg_print_buffer_decl( " KERNEL: preempting core %p (%p).\n", this_processor, this_thread); 335 331 336 332 TL_GET( preemption_state ).in_progress = true; // Sync flag : prevent recursive calls to the signal handler
Note:
See TracChangeset
for help on using the changeset viewer.