Changeset b21c77a for src/libcfa/concurrency/preemption.c
- Timestamp:
- Jun 29, 2018, 4:14:15 PM (7 years ago)
- Branches:
- new-env
- Children:
- 184557e
- Parents:
- 97397a26 (diff), 28f3a19 (diff)
Note: this is a merge changeset, the changes displayed below correspond to the merge itself.
Use the(diff)
links above to see all the changes relative to each parent. - File:
-
- 1 edited
Legend:
- Unmodified
- Added
- Removed
-
src/libcfa/concurrency/preemption.c
r97397a26 rb21c77a 10 10 // Created On : Mon Jun 5 14:20:42 2017 11 11 // Last Modified By : Peter A. Buhr 12 // Last Modified On : Mon Apr 9 13:52:39 201813 // Update Count : 3 612 // Last Modified On : Tue Jun 5 17:35:49 2018 13 // Update Count : 37 14 14 // 15 15 … … 116 116 // If there are still alarms pending, reset the timer 117 117 if( alarms->head ) { 118 __cfaabi_dbg_print_buffer_decl( " KERNEL: @% lu(%lu) resetting alarm to %lu.\n", currtime.tv, __kernel_get_time().tv, (alarms->head->alarm - currtime).tv);118 __cfaabi_dbg_print_buffer_decl( " KERNEL: @%ju(%ju) resetting alarm to %ju.\n", currtime.tv, __kernel_get_time().tv, (alarms->head->alarm - currtime).tv); 119 119 Duration delta = alarms->head->alarm - currtime; 120 120 Duration caped = max(delta, 50`us); … … 161 161 void disable_interrupts() { 162 162 with( kernelTLS.preemption_state ) { 163 #if GCC_VERSION > 50000 163 164 static_assert(__atomic_always_lock_free(sizeof(enabled), &enabled), "Must be lock-free"); 165 #endif 164 166 165 167 // Set enabled flag to false … … 190 192 // Check if we need to prempt the thread because an interrupt was missed 191 193 if( prev == 1 ) { 194 #if GCC_VERSION > 50000 192 195 static_assert(__atomic_always_lock_free(sizeof(enabled), &enabled), "Must be lock-free"); 196 #endif 193 197 194 198 // Set enabled flag to true … … 217 221 verifyf( prev != 0u, "Incremented from %u\n", prev ); // If this triggers someone is enabled already enabled interrupts 218 222 if( prev == 1 ) { 223 #if GCC_VERSION > 50000 219 224 static_assert(__atomic_always_lock_free(sizeof(kernelTLS.preemption_state.enabled), &kernelTLS.preemption_state.enabled), "Must be lock-free"); 225 #endif 220 226 // Set enabled flag to true 221 227 // should be atomic to avoid preemption in the middle of the operation. … … 254 260 static void preempt( processor * this ) { 255 261 sigval_t value = { PREEMPT_NORMAL }; 256 pthread_sigqueue( this->kernel_thread, SIGUSR1, value );257 }258 259 // kill wrapper : signal a processor260 void terminate(processor * this) {261 this->do_terminate = true;262 sigval_t value = { PREEMPT_TERMINATE };263 262 pthread_sigqueue( this->kernel_thread, SIGUSR1, value ); 264 263 } … … 362 361 choose(sfp->si_value.sival_int) { 363 362 case PREEMPT_NORMAL : ;// Normal case, nothing to do here 364 case PREEMPT_TERMINATE: verify( kernelTLS.this_processor->do_terminate);363 case PREEMPT_TERMINATE: verify( __atomic_load_n( &kernelTLS.this_processor->do_terminate, __ATOMIC_SEQ_CST ) ); 365 364 default: 366 365 abort( "internal error, signal value is %d", sfp->si_value.sival_int ); … … 376 375 377 376 // Clear sighandler mask before context switching. 377 #if GCC_VERSION > 50000 378 378 static_assert( sizeof( sigset_t ) == sizeof( cxt->uc_sigmask ), "Expected cxt->uc_sigmask to be of sigset_t" ); 379 #endif 379 380 if ( pthread_sigmask( SIG_SETMASK, (sigset_t *)&(cxt->uc_sigmask), NULL ) == -1 ) { 380 381 abort( "internal error, sigprocmask" ); … … 479 480 } 480 481 482 #ifdef __CFA_WITH_VERIFY__ 483 bool __cfaabi_dbg_in_kernel() { 484 return !kernelTLS.preemption_state.enabled; 485 } 486 #endif 487 481 488 // Local Variables: // 482 489 // mode: c //
Note:
See TracChangeset
for help on using the changeset viewer.