Changeset 7222630


Ignore:
Timestamp:
Jan 14, 2021, 1:13:47 PM (8 months ago)
Author:
Thierry Delisle <tdelisle@…>
Branches:
arm-eh, jacob/cs343-translation, master, new-ast-unique-expr
Children:
03ecdcf, 54cc2bf, ee59ede
Parents:
b0f6190a
Message:

Small refector so only preemption cares about signal

Location:
libcfa/src/concurrency
Files:
2 edited

Legend:

Unmodified
Added
Removed
  • libcfa/src/concurrency/io/setup.cfa

    rb0f6190a r7222630  
    314314        }
    315315
    316         extern void signal_block( int sig );
    317         extern void signal_unblock( int sig );
     316        extern void __disable_interrupts_hard();
     317        extern void __enable_interrupts_hard();
    318318
    319319        static void __io_create( __io_data & this, const io_context_params & params_in ) {
     
    434434                // io_uring_register is so f*cking slow on some machine that it
    435435                // will never succeed if preemption isn't hard blocked
    436                 signal_block( SIGUSR1 );
     436                __disable_interrupts_hard();
    437437
    438438                int efd = eventfd(0, 0);
     
    446446                }
    447447
    448                 signal_unblock( SIGUSR1 );
     448                __enable_interrupts_hard();
    449449
    450450                // some paranoid checks
  • libcfa/src/concurrency/preemption.cfa

    rb0f6190a r7222630  
    394394
    395395// sigprocmask wrapper : unblock a single signal
    396 void signal_unblock( int sig ) {
     396static inline void signal_unblock( int sig ) {
    397397        sigset_t mask;
    398398        sigemptyset( &mask );
     
    405405
    406406// sigprocmask wrapper : block a single signal
    407 void signal_block( int sig ) {
     407static inline void signal_block( int sig ) {
    408408        sigset_t mask;
    409409        sigemptyset( &mask );
     
    424424static void timeout( $thread * this ) {
    425425        unpark( this );
     426}
     427
     428void __disable_interrupts_hard() {
     429        sigset_t oldset;
     430        int ret;
     431        ret = pthread_sigmask(0, ( const sigset_t * ) 0p, &oldset);  // workaround trac#208: cast should be unnecessary
     432        if(ret != 0) { abort("ERROR sigprocmask returned %d", ret); }
     433
     434        ret = sigismember(&oldset, SIGUSR1);
     435        if(ret <  0) { abort("ERROR sigismember returned %d", ret); }
     436        if(ret == 1) { abort("ERROR SIGUSR1 is disabled"); }
     437
     438        ret = sigismember(&oldset, SIGALRM);
     439        if(ret <  0) { abort("ERROR sigismember returned %d", ret); }
     440        if(ret == 0) { abort("ERROR SIGALRM is enabled"); }
     441
     442        signal_block( SIGUSR1 );
     443}
     444
     445void __enable_interrupts_hard() {
     446        signal_unblock( SIGUSR1 );
     447
     448        sigset_t oldset;
     449        int ret;
     450        ret = pthread_sigmask(0, ( const sigset_t * ) 0p, &oldset);  // workaround trac#208: cast should be unnecessary
     451        if(ret != 0) { abort("ERROR sigprocmask returned %d", ret); }
     452
     453        ret = sigismember(&oldset, SIGUSR1);
     454        if(ret <  0) { abort("ERROR sigismember returned %d", ret); }
     455        if(ret == 1) { abort("ERROR SIGUSR1 is disabled"); }
     456
     457        ret = sigismember(&oldset, SIGALRM);
     458        if(ret <  0) { abort("ERROR sigismember returned %d", ret); }
     459        if(ret == 0) { abort("ERROR SIGALRM is enabled"); }
    426460}
    427461
Note: See TracChangeset for help on using the changeset viewer.