Changeset 36982fc for src/libcfa/concurrency/preemption.c
- Timestamp:
- Nov 29, 2017, 2:50:33 PM (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:
- 875a72f
- Parents:
- 8a0a64d9
- File:
-
- 1 edited
Legend:
- Unmodified
- Added
- Removed
-
src/libcfa/concurrency/preemption.c
r8a0a64d9 r36982fc 148 148 //============================================================================================= 149 149 150 LIB_DEBUG_DO( static thread_local void * last_interrupt = 0; )150 __cfaabi_dbg_debug_do( static thread_local void * last_interrupt = 0; ) 151 151 152 152 extern "C" { … … 159 159 // Enable interrupts by decrementing the counter 160 160 // If counter reaches 0, execute any pending CtxSwitch 161 void enable_interrupts( DEBUG_CTX_PARAM) {161 void enable_interrupts( __cfaabi_dbg_ctx_param ) { 162 162 processor * proc = this_processor; // Cache the processor now since interrupts can start happening after the atomic add 163 163 thread_desc * thrd = this_thread; // Cache the thread now since interrupts can start happening after the atomic add … … 173 173 174 174 // For debugging purposes : keep track of the last person to enable the interrupts 175 LIB_DEBUG_DO( proc->last_enable = caller; )175 __cfaabi_dbg_debug_do( proc->last_enable = caller; ) 176 176 } 177 177 … … 233 233 // Called from kernel_startup 234 234 void kernel_start_preemption() { 235 LIB_DEBUG_PRINT_SAFE("Kernel : Starting preemption\n");235 __cfaabi_dbg_print_safe("Kernel : Starting preemption\n"); 236 236 237 237 // Start with preemption disabled until ready … … 255 255 // Called from kernel_shutdown 256 256 void kernel_stop_preemption() { 257 LIB_DEBUG_PRINT_SAFE("Kernel : Preemption stopping\n");257 __cfaabi_dbg_print_safe("Kernel : Preemption stopping\n"); 258 258 259 259 // Block all signals since we are already shutting down … … 271 271 // Preemption is now fully stopped 272 272 273 LIB_DEBUG_PRINT_SAFE("Kernel : Preemption stopped\n");273 __cfaabi_dbg_print_safe("Kernel : Preemption stopped\n"); 274 274 } 275 275 … … 297 297 // Receives SIGUSR1 signal and causes the current thread to yield 298 298 void sigHandler_ctxSwitch( __CFA_SIGPARMS__ ) { 299 LIB_DEBUG_DO( last_interrupt = (void *)(cxt->uc_mcontext.gregs[CFA_REG_IP]); )299 __cfaabi_dbg_debug_do( last_interrupt = (void *)(cxt->uc_mcontext.gregs[CFA_REG_IP]); ) 300 300 301 301 // Check if it is safe to preempt here … … 346 346 assertf(sig == SIGALRM, "Kernel Internal Error, sigwait: Unexpected signal %d (%d : %d)\n", sig, info.si_code, info.si_value.sival_int); 347 347 348 // LIB_DEBUG_PRINT_SAFE("Kernel : Caught alarm from %d with %d\n", info.si_code, info.si_value.sival_int );348 // __cfaabi_dbg_print_safe("Kernel : Caught alarm from %d with %d\n", info.si_code, info.si_value.sival_int ); 349 349 // Switch on the code (a.k.a. the sender) to 350 350 switch( info.si_code ) … … 354 354 case SI_TIMER: 355 355 case SI_KERNEL: 356 // LIB_DEBUG_PRINT_SAFE("Kernel : Preemption thread tick\n");357 lock( event_kernel->lock DEBUG_CTX2 );356 // __cfaabi_dbg_print_safe("Kernel : Preemption thread tick\n"); 357 lock( event_kernel->lock __cfaabi_dbg_ctx2 ); 358 358 tick_preemption(); 359 359 unlock( event_kernel->lock ); … … 368 368 369 369 EXIT: 370 LIB_DEBUG_PRINT_SAFE("Kernel : Preemption thread stopping\n");370 __cfaabi_dbg_print_safe("Kernel : Preemption thread stopping\n"); 371 371 return NULL; 372 372 } … … 380 380 381 381 if ( sigaction( sig, &act, NULL ) == -1 ) { 382 LIB_DEBUG_PRINT_BUFFER_DECL(382 __cfaabi_dbg_print_buffer_decl( 383 383 " __kernel_sigaction( sig:%d, handler:%p, flags:%d ), problem installing signal handler, error(%d) %s.\n", 384 384 sig, handler, flags, errno, strerror( errno ) … … 397 397 398 398 if ( sigaction( sig, &act, NULL ) == -1 ) { 399 LIB_DEBUG_PRINT_BUFFER_DECL(399 __cfaabi_dbg_print_buffer_decl( 400 400 " __kernel_sigdefault( sig:%d ), problem reseting signal handler, error(%d) %s.\n", 401 401 sig, errno, strerror( errno ) … … 409 409 //============================================================================================= 410 410 411 LIB_DEBUG_DO(411 __cfaabi_dbg_debug_do( 412 412 static void __kernel_backtrace( int start ) { 413 413 // skip first N stack frames … … 476 476 477 477 // void sigHandler_segv( __CFA_SIGPARMS__ ) { 478 // LIB_DEBUG_DO(478 // __cfaabi_dbg_debug_do( 479 479 // #ifdef __USE_STREAM__ 480 480 // serr | "*CFA runtime error* program cfa-cpp terminated with" … … 493 493 // void sigHandler_abort( __CFA_SIGPARMS__ ) { 494 494 // // skip first 6 stack frames 495 // LIB_DEBUG_DO( __kernel_backtrace( 6 ); )495 // __cfaabi_dbg_debug_do( __kernel_backtrace( 6 ); ) 496 496 497 497 // // reset default signal handler
Note: See TracChangeset
for help on using the changeset viewer.