- File:
-
- 1 edited
-
src/libcfa/concurrency/preemption.c (modified) (3 diffs)
Legend:
- Unmodified
- Added
- Removed
-
src/libcfa/concurrency/preemption.c
rb68fc85 r7958e67 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 } … … 404 400 } 405 401 406 //=============================================================================================407 // Kernel Signal Debug408 //=============================================================================================409 410 void __cfaabi_check_preemption() {411 bool ready = TL_GET( preemption_state ).enabled;412 if(!ready) { abort("Preemption should be ready"); }413 414 sigset_t oldset;415 int ret;416 ret = sigprocmask(0, NULL, &oldset);417 if(ret != 0) { abort("ERROR sigprocmask returned %d", ret); }418 419 ret = sigismember(&oldset, SIGUSR1);420 if(ret < 0) { abort("ERROR sigismember returned %d", ret); }421 422 if(ret == 1) { abort("ERROR SIGUSR1 is disabled"); }423 }424 425 402 // Local Variables: // 426 403 // mode: c //
Note:
See TracChangeset
for help on using the changeset viewer.