Changeset a83ffa4


Ignore:
Timestamp:
May 18, 2018, 3:24:12 PM (6 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, with_gc
Children:
cb6314e
Parents:
b1a4300
Message:

Preemption now properly restore signal before context switching

Location:
src
Files:
2 edited

Legend:

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

    rb1a4300 ra83ffa4  
    1515
    1616#include "preemption.h"
     17#include <assert.h>
    1718
    1819extern "C" {
     
    350351        kernelTLS.preemption_state.in_progress = true;
    351352
    352         // We are about to CtxSwitch out of the signal handler, let other handlers in
    353         signal_unblock( SIGUSR1 );
     353        // Clear sighandler mask before context switching.
     354        static_assert( sizeof( sigset_t ) == sizeof( cxt->uc_sigmask ), "Expected cxt->uc_sigmask to be of sigset_t" );
     355        if ( pthread_sigmask( SIG_SETMASK, (sigset_t *)&(cxt->uc_sigmask), NULL ) == -1 ) {
     356                abort( "internal error, sigprocmask" );
     357        }
    354358
    355359        // TODO: this should go in finish action
     
    435439        sigset_t oldset;
    436440        int ret;
    437         ret = sigprocmask(0, NULL, &oldset);
     441        ret = pthread_sigmask(0, NULL, &oldset);
    438442        if(ret != 0) { abort("ERROR sigprocmask returned %d", ret); }
    439443
    440444        ret = sigismember(&oldset, SIGUSR1);
    441445        if(ret <  0) { abort("ERROR sigismember returned %d", ret); }
    442 
    443446        if(ret == 1) { abort("ERROR SIGUSR1 is disabled"); }
     447
     448        ret = sigismember(&oldset, SIGALRM);
     449        if(ret <  0) { abort("ERROR sigismember returned %d", ret); }
     450        if(ret == 0) { abort("ERROR SIGALRM is enabled"); }
     451
     452        ret = sigismember(&oldset, SIGTERM);
     453        if(ret <  0) { abort("ERROR sigismember returned %d", ret); }
     454        if(ret == 1) { abort("ERROR SIGTERM is disabled"); }
    444455}
    445456
  • src/tests/concurrent/preempt.c

    rb1a4300 ra83ffa4  
    4444
    4545int main(int argc, char* argv[]) {
    46         processor p;
     46        // processor p;
    4747        {
    4848                worker_t w0 = 0;
Note: See TracChangeset for help on using the changeset viewer.