- File:
-
- 1 edited
-
src/libcfa/concurrency/preemption.c (modified) (6 diffs)
Legend:
- Unmodified
- Added
- Removed
-
src/libcfa/concurrency/preemption.c
r381fdee r4dad189 10 10 // Created On : Mon Jun 5 14:20:42 2017 11 11 // Last Modified By : Peter A. Buhr 12 // Last Modified On : Fri Feb 9 14:42:34201813 // Update Count : 2512 // Last Modified On : Tue Feb 6 15:00:36 2018 13 // Update Count : 10 14 14 // 15 15 16 16 #include "preemption.h" 17 17 18 #define ftype `ftype` 18 19 extern "C" { 19 20 #include <errno.h> … … 22 23 #include <unistd.h> 23 24 } 25 #undef ftype 24 26 25 27 #include "bits/signal.h" … … 48 50 49 51 // Machine specific register name 50 #if defined( __i386 ) 52 #if defined(__x86_64__) 53 #define CFA_REG_IP gregs[REG_RIP] 54 #elif defined(__i386__) 51 55 #define CFA_REG_IP gregs[REG_EIP] 52 #elif defined( __x86_64 ) 53 #define CFA_REG_IP gregs[REG_RIP] 54 #elif defined( __ARM_ARCH ) 56 #elif defined(__ARM_ARCH__) 55 57 #define CFA_REG_IP arm_pc 56 #else57 #error unknown hardware architecture58 58 #endif 59 59 … … 66 66 lock{}; 67 67 } 68 69 enum { 70 PREEMPT_NORMAL = 0, 71 PREEMPT_TERMINATE = 1, 72 }; 68 73 69 74 //============================================================================================= … … 209 214 // kill wrapper : signal a processor 210 215 static void preempt( processor * this ) { 211 pthread_kill( this->kernel_thread, SIGUSR1 ); 216 sigval_t value = { PREEMPT_NORMAL }; 217 pthread_sigqueue( this->kernel_thread, SIGUSR1, value ); 218 } 219 220 // kill wrapper : signal a processor 221 void terminate(processor * this) { 222 this->do_terminate = true; 223 sigval_t value = { PREEMPT_TERMINATE }; 224 pthread_sigqueue( this->kernel_thread, SIGUSR1, value ); 212 225 } 213 226 … … 298 311 void sigHandler_ctxSwitch( __CFA_SIGPARMS__ ) { 299 312 __cfaabi_dbg_debug_do( last_interrupt = (void *)(cxt->uc_mcontext.CFA_REG_IP); ) 313 314 // SKULLDUGGERY: if a thread creates a processor and the immediately deletes it, 315 // the interrupt that is supposed to force the kernel thread to preempt might arrive 316 // before the kernel thread has even started running. When that happens an iterrupt 317 // we a null 'this_processor' will be caught, just ignore it. 318 if(!this_processor) return; 319 320 choose(sfp->si_value.sival_int) { 321 case PREEMPT_NORMAL : ;// Normal case, nothing to do here 322 case PREEMPT_TERMINATE: verify(this_processor->do_terminate); 323 default: 324 abortf( "internal error, signal value is %d", sfp->si_value.sival_int ); 325 } 300 326 301 327 // Check if it is safe to preempt here
Note:
See TracChangeset
for help on using the changeset viewer.