Ignore:
File:
1 edited

Legend:

Unmodified
Added
Removed
  • src/libcfa/concurrency/preemption.c

    ra0b3e32 rf2b12406  
    222222        sigprocmask( SIG_BLOCK, &mask, NULL );
    223223
    224         sigval val = { 1 };
    225         pthread_sigqueue( alarm_thread, SIGALRM, val );
     224        pthread_kill( alarm_thread, SIGINT );
    226225        pthread_join( alarm_thread, NULL );
    227226        LIB_DEBUG_PRINT_SAFE("Kernel : Preemption stopped\n");
     
    282281        sigemptyset( &mask );
    283282        sigaddset( &mask, SIGALRM );
     283        sigaddset( &mask, SIGUSR2 );
     284        sigaddset( &mask, SIGINT  );
    284285
    285286        if ( pthread_sigmask( SIG_BLOCK, &mask, NULL ) == -1 ) {
     
    288289
    289290        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  ) {
    293293                        abortf( "internal error, sigwait" );
    294294                }
    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:
    300298                                LIB_DEBUG_PRINT_SAFE("Kernel : Preemption thread tick\n");
    301299                                lock( &systemProcessor->alarm_lock DEBUG_CTX2 );
    302300                                tick_preemption();
    303301                                unlock( &systemProcessor->alarm_lock );
    304                         }
    305                         else if( info.si_value.sival_int == 1 )
    306                         {
    307302                                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        }
    318314}
    319315
Note: See TracChangeset for help on using the changeset viewer.