Ignore:
Timestamp:
Jun 27, 2018, 3:28:41 PM (7 years ago)
Author:
Aaron Moss <a3moss@…>
Branches:
new-env, with_gc
Children:
b21c77a
Parents:
0182bfa (diff), 63238a4 (diff)
Note: this is a merge changeset, the changes displayed below correspond to the merge itself.
Use the (diff) links above to see all the changes relative to each parent.
Message:

Merge branch 'master' into with_gc

File:
1 edited

Legend:

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

    r0182bfa r28f3a19  
    1010// Created On       : Mon Jun 5 14:20:42 2017
    1111// Last Modified By : Peter A. Buhr
    12 // Last Modified On : Mon Apr  9 13:52:39 2018
    13 // Update Count     : 36
     12// Last Modified On : Tue Jun  5 17:35:49 2018
     13// Update Count     : 37
    1414//
    1515
     
    116116        // If there are still alarms pending, reset the timer
    117117        if( alarms->head ) {
    118                 __cfaabi_dbg_print_buffer_decl( " KERNEL: @%lu(%lu) resetting alarm to %lu.\n", currtime.tv, __kernel_get_time().tv, (alarms->head->alarm - currtime).tv);
     118                __cfaabi_dbg_print_buffer_decl( " KERNEL: @%ju(%ju) resetting alarm to %ju.\n", currtime.tv, __kernel_get_time().tv, (alarms->head->alarm - currtime).tv);
    119119                Duration delta = alarms->head->alarm - currtime;
    120120                Duration caped = max(delta, 50`us);
     
    161161        void disable_interrupts() {
    162162                with( kernelTLS.preemption_state ) {
     163                        #if GCC_VERSION > 50000
    163164                        static_assert(__atomic_always_lock_free(sizeof(enabled), &enabled), "Must be lock-free");
     165                        #endif
    164166
    165167                        // Set enabled flag to false
     
    190192                        // Check if we need to prempt the thread because an interrupt was missed
    191193                        if( prev == 1 ) {
     194                                #if GCC_VERSION > 50000
    192195                                static_assert(__atomic_always_lock_free(sizeof(enabled), &enabled), "Must be lock-free");
     196                                #endif
    193197
    194198                                // Set enabled flag to true
     
    217221                verifyf( prev != 0u, "Incremented from %u\n", prev );                     // If this triggers someone is enabled already enabled interrupts
    218222                if( prev == 1 ) {
     223                        #if GCC_VERSION > 50000
    219224                        static_assert(__atomic_always_lock_free(sizeof(kernelTLS.preemption_state.enabled), &kernelTLS.preemption_state.enabled), "Must be lock-free");
     225                        #endif
    220226                        // Set enabled flag to true
    221227                        // should be atomic to avoid preemption in the middle of the operation.
     
    254260static void preempt( processor * this ) {
    255261        sigval_t value = { PREEMPT_NORMAL };
    256         pthread_sigqueue( this->kernel_thread, SIGUSR1, value );
    257 }
    258 
    259 // kill wrapper : signal a processor
    260 void terminate(processor * this) {
    261         this->do_terminate = true;
    262         sigval_t value = { PREEMPT_TERMINATE };
    263262        pthread_sigqueue( this->kernel_thread, SIGUSR1, value );
    264263}
     
    362361        choose(sfp->si_value.sival_int) {
    363362                case PREEMPT_NORMAL   : ;// Normal case, nothing to do here
    364                 case PREEMPT_TERMINATE: verify( kernelTLS.this_processor->do_terminate);
     363                case PREEMPT_TERMINATE: verify( __atomic_load_n( &kernelTLS.this_processor->do_terminate, __ATOMIC_SEQ_CST ) );
    365364                default:
    366365                        abort( "internal error, signal value is %d", sfp->si_value.sival_int );
     
    376375
    377376        // Clear sighandler mask before context switching.
     377        #if GCC_VERSION > 50000
    378378        static_assert( sizeof( sigset_t ) == sizeof( cxt->uc_sigmask ), "Expected cxt->uc_sigmask to be of sigset_t" );
     379        #endif
    379380        if ( pthread_sigmask( SIG_SETMASK, (sigset_t *)&(cxt->uc_sigmask), NULL ) == -1 ) {
    380381                abort( "internal error, sigprocmask" );
     
    479480}
    480481
     482#ifdef __CFA_WITH_VERIFY__
     483bool __cfaabi_dbg_in_kernel() {
     484        return !kernelTLS.preemption_state.enabled;
     485}
     486#endif
     487
    481488// Local Variables: //
    482489// mode: c //
Note: See TracChangeset for help on using the changeset viewer.