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