Ignore:
File:
1 edited

Legend:

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

    r804c0ff r6011658  
    140140                preemption_scope scope = { this };
    141141
    142                 #if !defined(__CFA_NO_STATISTICS__)
    143                         unsigned long long last_tally = rdtscl();
    144                 #endif
    145 
    146 
    147142                __cfadbg_print_safe(runtime_core, "Kernel : core %p started\n", this);
    148143
     
    211206                        // Are we done?
    212207                        if( __atomic_load_n(&this->do_terminate, __ATOMIC_SEQ_CST) ) break MAIN_LOOP;
    213 
    214                         #if !defined(__CFA_NO_STATISTICS__)
    215                                 unsigned long long curr = rdtscl();
    216                                 if(curr > (last_tally + 500000000)) {
    217                                         __tally_stats(this->cltr->stats, __cfaabi_tls.this_stats);
    218                                         last_tally = curr;
    219                                 }
    220                         #endif
    221208                }
    222209
     
    624611// Unexpected Terminating logic
    625612//=============================================================================================
    626 
    627 extern "C" {
    628         extern void __cfaabi_real_abort(void);
    629 }
    630 static volatile bool kernel_abort_called = false;
     613static __spinlock_t kernel_abort_lock;
     614static bool kernel_abort_called = false;
    631615
    632616void * kernel_abort(void) __attribute__ ((__nothrow__)) {
    633617        // abort cannot be recursively entered by the same or different processors because all signal handlers return when
    634618        // the globalAbort flag is true.
    635         bool first = __atomic_test_and_set( &kernel_abort_called, __ATOMIC_SEQ_CST);
    636 
    637         // first task to abort ?
    638         if ( !first ) {
    639                 // We aren't the first to abort.
    640                 // I give up, just let C handle it
    641                 __cfaabi_real_abort();
    642         }
     619        lock( kernel_abort_lock __cfaabi_dbg_ctx2 );
    643620
    644621        // disable interrupts, it no longer makes sense to try to interrupt this processor
    645622        disable_interrupts();
     623
     624        // first task to abort ?
     625        if ( kernel_abort_called ) {                    // not first task to abort ?
     626                unlock( kernel_abort_lock );
     627
     628                sigset_t mask;
     629                sigemptyset( &mask );
     630                sigaddset( &mask, SIGALRM );            // block SIGALRM signals
     631                sigaddset( &mask, SIGUSR1 );            // block SIGALRM signals
     632                sigsuspend( &mask );                            // block the processor to prevent further damage during abort
     633                _exit( EXIT_FAILURE );                          // if processor unblocks before it is killed, terminate it
     634        }
     635        else {
     636                kernel_abort_called = true;
     637                unlock( kernel_abort_lock );
     638        }
    646639
    647640        return __cfaabi_tls.this_thread;
Note: See TracChangeset for help on using the changeset viewer.