Changeset a0b3e32 for src/libcfa


Ignore:
Timestamp:
Jul 13, 2017, 1:50:57 PM (7 years ago)
Author:
Thierry Delisle <tdelisle@…>
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:
35b06a8
Parents:
acb89ed
Message:

Alarmloop no longer uses signals other than SIGALRM

File:
1 edited

Legend:

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

    racb89ed ra0b3e32  
    222222        sigprocmask( SIG_BLOCK, &mask, NULL );
    223223
    224         pthread_kill( alarm_thread, SIGINT );
     224        sigval val = { 1 };
     225        pthread_sigqueue( alarm_thread, SIGALRM, val );
    225226        pthread_join( alarm_thread, NULL );
    226227        LIB_DEBUG_PRINT_SAFE("Kernel : Preemption stopped\n");
     
    281282        sigemptyset( &mask );
    282283        sigaddset( &mask, SIGALRM );
    283         sigaddset( &mask, SIGUSR2 );
    284         sigaddset( &mask, SIGINT  );
    285284
    286285        if ( pthread_sigmask( SIG_BLOCK, &mask, NULL ) == -1 ) {
     
    289288
    290289        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 ) {
    293293                        abortf( "internal error, sigwait" );
    294294                }
    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                        {
    298300                                LIB_DEBUG_PRINT_SAFE("Kernel : Preemption thread tick\n");
    299301                                lock( &systemProcessor->alarm_lock DEBUG_CTX2 );
    300302                                tick_preemption();
    301303                                unlock( &systemProcessor->alarm_lock );
     304                        }
     305                        else if( info.si_value.sival_int == 1 )
     306                        {
    302307                                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;
    314318}
    315319
Note: See TracChangeset for help on using the changeset viewer.