- File:
-
- 1 edited
-
src/libcfa/concurrency/preemption.c (modified) (8 diffs)
Legend:
- Unmodified
- Added
- Removed
-
src/libcfa/concurrency/preemption.c
rd8548e2 rb69ea6b 23 23 } 24 24 25 #include "bits/cfatime.h"26 25 #include "bits/signal.h" 27 26 28 #if !defined(__CFA_DEFAULT_PREEMPTION__) 29 #define __CFA_DEFAULT_PREEMPTION__ 10 `cfa_ms30 #endif 31 32 __ cfa_time_t default_preemption() __attribute__((weak)) {27 //TODO move to defaults 28 #define __CFA_DEFAULT_PREEMPTION__ 10000 29 30 //TODO move to defaults 31 __attribute__((weak)) unsigned int default_preemption() { 33 32 return __CFA_DEFAULT_PREEMPTION__; 34 33 } … … 150 149 // Disable interrupts by incrementing the counter 151 150 void disable_interrupts() { 152 preemption _state.enabled = false;153 __attribute__((unused)) unsigned short new_val = preemption _state.disable_count + 1;154 preemption _state.disable_count = new_val;151 preemption.enabled = false; 152 __attribute__((unused)) unsigned short new_val = preemption.disable_count + 1; 153 preemption.disable_count = new_val; 155 154 verify( new_val < 65_000u ); // If this triggers someone is disabling interrupts without enabling them 156 155 } … … 162 161 thread_desc * thrd = this_thread; // Cache the thread now since interrupts can start happening after the atomic add 163 162 164 unsigned short prev = preemption _state.disable_count;165 preemption _state.disable_count -= 1;163 unsigned short prev = preemption.disable_count; 164 preemption.disable_count -= 1; 166 165 verify( prev != 0u ); // If this triggers someone is enabled already enabled interruptsverify( prev != 0u ); 167 166 168 167 // Check if we need to prempt the thread because an interrupt was missed 169 168 if( prev == 1 ) { 170 preemption _state.enabled = true;169 preemption.enabled = true; 171 170 if( proc->pending_preemption ) { 172 171 proc->pending_preemption = false; … … 182 181 // Don't execute any pending CtxSwitch even if counter reaches 0 183 182 void enable_interrupts_noPoll() { 184 unsigned short prev = preemption _state.disable_count;185 preemption _state.disable_count -= 1;183 unsigned short prev = preemption.disable_count; 184 preemption.disable_count -= 1; 186 185 verifyf( prev != 0u, "Incremented from %u\n", prev ); // If this triggers someone is enabled already enabled interrupts 187 186 if( prev == 1 ) { 188 preemption _state.enabled = true;187 preemption.enabled = true; 189 188 } 190 189 } … … 236 235 // If false : preemption is unsafe and marked as pending 237 236 static inline bool preemption_ready() { 238 bool ready = preemption _state.enabled && !preemption_state.in_progress; // Check if preemption is safe237 bool ready = preemption.enabled && !preemption.in_progress; // Check if preemption is safe 239 238 this_processor->pending_preemption = !ready; // Adjust the pending flag accordingly 240 239 return ready; … … 251 250 252 251 // Start with preemption disabled until ready 253 preemption _state.enabled = false;254 preemption _state.disable_count = 1;252 preemption.enabled = false; 253 preemption.disable_count = 1; 255 254 256 255 // Initialize the event kernel … … 295 294 this.proc->preemption_alarm = &this.alarm; 296 295 297 update_preemption( this.proc, this.proc->cltr->preemption_rate);296 update_preemption( this.proc, from_us(this.proc->cltr->preemption) ); 298 297 } 299 298 … … 331 330 __cfaabi_dbg_print_buffer_decl( " KERNEL: preempting core %p (%p).\n", this_processor, this_thread); 332 331 333 preemption _state.in_progress = true; // Sync flag : prevent recursive calls to the signal handler332 preemption.in_progress = true; // Sync flag : prevent recursive calls to the signal handler 334 333 signal_unblock( SIGUSR1 ); // We are about to CtxSwitch out of the signal handler, let other handlers in 335 preemption _state.in_progress = false; // Clear the in progress flag334 preemption.in_progress = false; // Clear the in progress flag 336 335 337 336 // Preemption can occur here
Note:
See TracChangeset
for help on using the changeset viewer.