- File:
-
- 1 edited
Legend:
- Unmodified
- Added
- Removed
-
src/libcfa/concurrency/preemption.c
ra0b3e32 rf2b12406 222 222 sigprocmask( SIG_BLOCK, &mask, NULL ); 223 223 224 sigval val = { 1 }; 225 pthread_sigqueue( alarm_thread, SIGALRM, val ); 224 pthread_kill( alarm_thread, SIGINT ); 226 225 pthread_join( alarm_thread, NULL ); 227 226 LIB_DEBUG_PRINT_SAFE("Kernel : Preemption stopped\n"); … … 282 281 sigemptyset( &mask ); 283 282 sigaddset( &mask, SIGALRM ); 283 sigaddset( &mask, SIGUSR2 ); 284 sigaddset( &mask, SIGINT ); 284 285 285 286 if ( pthread_sigmask( SIG_BLOCK, &mask, NULL ) == -1 ) { … … 288 289 289 290 while( true ) { 290 siginfo_t info; 291 int sig = sigwaitinfo( &mask, &info ); 292 if( sig < 0 ) { 291 int sig; 292 if( sigwait( &mask, &sig ) != 0 ) { 293 293 abortf( "internal error, sigwait" ); 294 294 } 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 { 295 296 switch( sig) { 297 case SIGALRM: 300 298 LIB_DEBUG_PRINT_SAFE("Kernel : Preemption thread tick\n"); 301 299 lock( &systemProcessor->alarm_lock DEBUG_CTX2 ); 302 300 tick_preemption(); 303 301 unlock( &systemProcessor->alarm_lock ); 304 }305 else if( info.si_value.sival_int == 1 )306 {307 302 break; 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; 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 } 318 314 } 319 315
Note:
See TracChangeset
for help on using the changeset viewer.