Changeset d56ca354 for src/libcfa/concurrency/preemption.c
- Timestamp:
- Feb 12, 2018, 11:57:55 AM (7 years ago)
- Branches:
- ADT, aaron-thesis, arm-eh, ast-experimental, cleanup-dtors, deferred_resn, demangler, enum, forall-pointer-decay, jacob/cs343-translation, jenkins-sandbox, master, new-ast, new-ast-unique-expr, new-env, no_list, persistent-indexer, pthread-emulation, qualifiedEnum, resolv-new, with_gc
- Children:
- fd062a66
- Parents:
- c40e7c5 (diff), cfe2f0a (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
rc40e7c5 rd56ca354 10 10 // Created On : Mon Jun 5 14:20:42 2017 11 11 // Last Modified By : Peter A. Buhr 12 // Last Modified On : Tue Feb 6 15:00:36201813 // Update Count : 1 012 // Last Modified On : Fri Feb 9 16:38:13 2018 13 // Update Count : 14 14 14 // 15 15 16 16 #include "preemption.h" 17 17 18 #define ftype `ftype`19 18 extern "C" { 20 19 #include <errno.h> … … 23 22 #include <unistd.h> 24 23 } 25 #undef ftype26 24 27 25 #include "bits/signal.h" … … 50 48 51 49 // Machine specific register name 52 #if defined(__x86_64__) 50 #if defined( __i386 ) 51 #define CFA_REG_IP gregs[REG_EIP] 52 #elif defined( __x86_64 ) 53 53 #define CFA_REG_IP gregs[REG_RIP] 54 #elif defined(__i386__) 55 #define CFA_REG_IP gregs[REG_EIP] 56 #elif defined(__ARM_ARCH__) 54 #elif defined( __ARM_ARCH ) 57 55 #define CFA_REG_IP arm_pc 56 #else 57 #error unknown hardware architecture 58 58 #endif 59 59 … … 197 197 198 198 if ( pthread_sigmask( SIG_UNBLOCK, &mask, NULL ) == -1 ) { 199 abort f( "internal error, pthread_sigmask" );199 abort( "internal error, pthread_sigmask" ); 200 200 } 201 201 } … … 208 208 209 209 if ( pthread_sigmask( SIG_BLOCK, &mask, NULL ) == -1 ) { 210 abort f( "internal error, pthread_sigmask" );210 abort( "internal error, pthread_sigmask" ); 211 211 } 212 212 } … … 247 247 // Called from kernel_startup 248 248 void kernel_start_preemption() { 249 __cfaabi_dbg_print_safe( "Kernel : Starting preemption\n");249 __cfaabi_dbg_print_safe( "Kernel : Starting preemption\n" ); 250 250 251 251 // Start with preemption disabled until ready … … 268 268 // Called from kernel_shutdown 269 269 void kernel_stop_preemption() { 270 __cfaabi_dbg_print_safe( "Kernel : Preemption stopping\n");270 __cfaabi_dbg_print_safe( "Kernel : Preemption stopping\n" ); 271 271 272 272 // Block all signals since we are already shutting down … … 284 284 // Preemption is now fully stopped 285 285 286 __cfaabi_dbg_print_safe( "Kernel : Preemption stopped\n");286 __cfaabi_dbg_print_safe( "Kernel : Preemption stopped\n" ); 287 287 } 288 288 … … 322 322 case PREEMPT_TERMINATE: verify(this_processor->do_terminate); 323 323 default: 324 abort f( "internal error, signal value is %d", sfp->si_value.sival_int );324 abort( "internal error, signal value is %d", sfp->si_value.sival_int ); 325 325 } 326 326 … … 328 328 if( !preemption_ready() ) { return; } 329 329 330 __cfaabi_dbg_print_buffer_decl( " KERNEL: preempting core %p (%p).\n", this_processor, this_thread);330 __cfaabi_dbg_print_buffer_decl( " KERNEL: preempting core %p (%p).\n", this_processor, this_thread); 331 331 332 332 preemption_in_progress = true; // Sync flag : prevent recursive calls to the signal handler … … 348 348 349 349 if ( pthread_sigmask( SIG_BLOCK, &mask, NULL ) == -1 ) { 350 abort f( "internal error, pthread_sigmask" );350 abort( "internal error, pthread_sigmask" ); 351 351 } 352 352 … … 365 365 continue; 366 366 case EINVAL : 367 abort f("Timeout was invalid.");367 abort( "Timeout was invalid." ); 368 368 default: 369 abort f("Unhandled error %d", err);369 abort( "Unhandled error %d", err); 370 370 } 371 371 } … … 374 374 assertf(sig == SIGALRM, "Kernel Internal Error, sigwait: Unexpected signal %d (%d : %d)\n", sig, info.si_code, info.si_value.sival_int); 375 375 376 // __cfaabi_dbg_print_safe( "Kernel : Caught alarm from %d with %d\n", info.si_code, info.si_value.sival_int );376 // __cfaabi_dbg_print_safe( "Kernel : Caught alarm from %d with %d\n", info.si_code, info.si_value.sival_int ); 377 377 // Switch on the code (a.k.a. the sender) to 378 378 switch( info.si_code ) … … 382 382 case SI_TIMER: 383 383 case SI_KERNEL: 384 // __cfaabi_dbg_print_safe( "Kernel : Preemption thread tick\n");384 // __cfaabi_dbg_print_safe( "Kernel : Preemption thread tick\n" ); 385 385 lock( event_kernel->lock __cfaabi_dbg_ctx2 ); 386 386 tick_preemption(); … … 396 396 397 397 EXIT: 398 __cfaabi_dbg_print_safe( "Kernel : Preemption thread stopping\n");398 __cfaabi_dbg_print_safe( "Kernel : Preemption thread stopping\n" ); 399 399 return NULL; 400 400 }
Note: See TracChangeset
for help on using the changeset viewer.