Changeset becb85b9 for libcfa


Ignore:
Timestamp:
Feb 4, 2022, 2:44:10 PM (3 years ago)
Author:
Thierry Delisle <tdelisle@…>
Branches:
ADT, ast-experimental, enum, forall-pointer-decay, master, pthread-emulation, qualifiedEnum
Children:
67e86ae6
Parents:
941e14a
Message:

Attempt to fix preemption deadlock.
No longer prevent preemption during cfaabi_check_preemption.
preemption_enabled() now does a roll forward if it blocked a preemption.

File:
1 edited

Legend:

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

    r941e14a rbecb85b9  
    251251        bool enabled = __cfaabi_tls.preemption_state.enabled;
    252252
     253        // Check if there is a pending preemption
     254        processor   * proc = __cfaabi_tls.this_processor;
     255        bool pending = proc ? proc->pending_preemption : false;
     256        if( enabled && pending ) proc->pending_preemption = false;
     257
    253258        // create a assembler label after
    254259        // marked as clobber all to avoid movement
    255260        __cfaasm_label(check, after);
     261
     262        // If we can preempt and there is a pending one
     263        // this is a good time to yield
     264        if( enabled && pending ) {
     265                force_yield( __POLL_PREEMPTION );
     266        }
    256267        return enabled;
    257268}
     
    282293        // marked as clobber all to avoid movement
    283294        __cfaasm_label(get, after);
     295
     296        // This is used everywhere, to avoid cost, we DO NOT poll pending preemption
    284297        return val;
    285298}
     
    358371        if(!ready) { abort("Preemption should be ready"); }
    359372
    360         __cfaasm_label(debug, before);
     373        // __cfaasm_label(debug, before);
    361374
    362375                sigset_t oldset;
     
    377390                if(ret == 1) { abort("ERROR SIGTERM is disabled"); }
    378391
    379         __cfaasm_label(debug, after);
     392        // __cfaasm_label(debug, after);
    380393}
    381394
     
    548561        __cfaasm_label( check  );
    549562        __cfaasm_label( dsable );
    550         __cfaasm_label( debug  );
     563        // __cfaasm_label( debug  );
    551564
    552565        // Check if preemption is safe
     
    555568        if( __cfaasm_in( ip, check  ) ) { ready = false; goto EXIT; };
    556569        if( __cfaasm_in( ip, dsable ) ) { ready = false; goto EXIT; };
    557         if( __cfaasm_in( ip, debug  ) ) { ready = false; goto EXIT; };
     570        // if( __cfaasm_in( ip, debug  ) ) { ready = false; goto EXIT; };
    558571        if( !__cfaabi_tls.preemption_state.enabled) { ready = false; goto EXIT; };
    559572        if( __cfaabi_tls.preemption_state.in_progress ) { ready = false; goto EXIT; };
Note: See TracChangeset for help on using the changeset viewer.