Changeset a0b3e32 for src/libcfa/concurrency/preemption.c
- Timestamp:
- Jul 13, 2017, 1:50:57 PM (6 years ago)
- Branches:
- aaron-thesis, arm-eh, 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:
- 35b06a8
- Parents:
- acb89ed
- File:
-
- 1 edited
Legend:
- Unmodified
- Added
- Removed
-
src/libcfa/concurrency/preemption.c
racb89ed ra0b3e32 222 222 sigprocmask( SIG_BLOCK, &mask, NULL ); 223 223 224 pthread_kill( alarm_thread, SIGINT ); 224 sigval val = { 1 }; 225 pthread_sigqueue( alarm_thread, SIGALRM, val ); 225 226 pthread_join( alarm_thread, NULL ); 226 227 LIB_DEBUG_PRINT_SAFE("Kernel : Preemption stopped\n"); … … 281 282 sigemptyset( &mask ); 282 283 sigaddset( &mask, SIGALRM ); 283 sigaddset( &mask, SIGUSR2 );284 sigaddset( &mask, SIGINT );285 284 286 285 if ( pthread_sigmask( SIG_BLOCK, &mask, NULL ) == -1 ) { … … 289 288 290 289 while( true ) { 291 int sig; 292 if( sigwait( &mask, &sig ) != 0 ) { 290 siginfo_t info; 291 int sig = sigwaitinfo( &mask, &info ); 292 if( sig < 0 ) { 293 293 abortf( "internal error, sigwait" ); 294 294 } 295 296 switch( sig) { 297 case SIGALRM: 295 else if( sig == SIGALRM ) 296 { 297 LIB_DEBUG_PRINT_SAFE("Kernel : Caught signal %d (%d)\n", sig, info.si_value.sival_int ); 298 if( info.si_value.sival_int == 0 ) 299 { 298 300 LIB_DEBUG_PRINT_SAFE("Kernel : Preemption thread tick\n"); 299 301 lock( &systemProcessor->alarm_lock DEBUG_CTX2 ); 300 302 tick_preemption(); 301 303 unlock( &systemProcessor->alarm_lock ); 304 } 305 else if( info.si_value.sival_int == 1 ) 306 { 302 307 break; 303 case SIGUSR2: 304 //TODO other actions 305 break; 306 case SIGINT: 307 LIB_DEBUG_PRINT_SAFE("Kernel : Preemption thread stopping\n"); 308 return NULL; 309 default: 310 abortf( "internal error, sigwait returned sig %d", sig ); 311 break; 312 } 313 } 308 } 309 } 310 else 311 { 312 LIB_DEBUG_PRINT_SAFE("Kernel : Unexpected signal %d (%d)\n", sig, info.si_value.sival_int); 313 } 314 } 315 316 LIB_DEBUG_PRINT_SAFE("Kernel : Preemption thread stopping\n"); 317 return NULL; 314 318 } 315 319
Note: See TracChangeset
for help on using the changeset viewer.