Ignore:
Timestamp:
May 29, 2018, 3:26:31 PM (7 years ago)
Author:
Rob Schluntz <rschlunt@…>
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:
3530f39a
Parents:
96812c0 (diff), da60c631 (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' of plg.uwaterloo.ca:/u/cforall/software/cfa/cfa-cc

Location:
src/libcfa/concurrency
Files:
2 edited

Legend:

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

    r96812c0 r054514d  
    1010// Created On       : Fri Jun 2 11:31:25 2017
    1111// Last Modified By : Peter A. Buhr
    12 // Last Modified On : Mon Apr  9 13:36:18 2018
    13 // Update Count     : 61
     12// Last Modified On : Fri May 25 06:25:47 2018
     13// Update Count     : 67
    1414//
    1515
     
    3737
    3838void __kernel_set_timer( Duration alarm ) {
    39         verifyf(alarm >= 1`us || alarm == 0, "Setting timer to < 1us (%luns)", alarm.tv);
     39        verifyf(alarm >= 1`us || alarm == 0, "Setting timer to < 1us (%jins)", alarm.tv);
    4040        setitimer( ITIMER_REAL, &(itimerval){ alarm }, NULL );
    4141}
  • src/libcfa/concurrency/preemption.c

    r96812c0 r054514d  
    161161        void disable_interrupts() {
    162162                with( kernelTLS.preemption_state ) {
    163                         enabled = false;
     163                        #if GCC_VERSION > 50000
     164                        static_assert(__atomic_always_lock_free(sizeof(enabled), &enabled), "Must be lock-free");
     165                        #endif
     166
     167                        // Set enabled flag to false
     168                        // should be atomic to avoid preemption in the middle of the operation.
     169                        // use memory order RELAXED since there is no inter-thread on this variable requirements
     170                        __atomic_store_n(&enabled, false, __ATOMIC_RELAXED);
     171
     172                        // Signal the compiler that a fence is needed but only for signal handlers
     173                        __atomic_signal_fence(__ATOMIC_ACQUIRE);
     174
    164175                        __attribute__((unused)) unsigned short new_val = disable_count + 1;
    165176                        disable_count = new_val;
     
    171182        // If counter reaches 0, execute any pending CtxSwitch
    172183        void enable_interrupts( __cfaabi_dbg_ctx_param ) {
    173                 processor   * proc = kernelTLS.this_processor; // Cache the processor now since interrupts can start happening after the atomic add
    174                 thread_desc * thrd = kernelTLS.this_thread;       // Cache the thread now since interrupts can start happening after the atomic add
     184                processor   * proc = kernelTLS.this_processor; // Cache the processor now since interrupts can start happening after the atomic store
     185                thread_desc * thrd = kernelTLS.this_thread;       // Cache the thread now since interrupts can start happening after the atomic store
    175186
    176187                with( kernelTLS.preemption_state ){
     
    181192                        // Check if we need to prempt the thread because an interrupt was missed
    182193                        if( prev == 1 ) {
    183                                 enabled = true;
     194                                #if GCC_VERSION > 50000
     195                                static_assert(__atomic_always_lock_free(sizeof(enabled), &enabled), "Must be lock-free");
     196                                #endif
     197
     198                                // Set enabled flag to true
     199                                // should be atomic to avoid preemption in the middle of the operation.
     200                                // use memory order RELAXED since there is no inter-thread on this variable requirements
     201                                __atomic_store_n(&enabled, true, __ATOMIC_RELAXED);
     202
     203                                // Signal the compiler that a fence is needed but only for signal handlers
     204                                __atomic_signal_fence(__ATOMIC_RELEASE);
    184205                                if( proc->pending_preemption ) {
    185206                                        proc->pending_preemption = false;
     
    200221                verifyf( prev != 0u, "Incremented from %u\n", prev );                     // If this triggers someone is enabled already enabled interrupts
    201222                if( prev == 1 ) {
    202                         kernelTLS.preemption_state.enabled = true;
     223                        #if GCC_VERSION > 50000
     224                        static_assert(__atomic_always_lock_free(sizeof(kernelTLS.preemption_state.enabled), &kernelTLS.preemption_state.enabled), "Must be lock-free");
     225                        #endif
     226                        // Set enabled flag to true
     227                        // should be atomic to avoid preemption in the middle of the operation.
     228                        // use memory order RELAXED since there is no inter-thread on this variable requirements
     229                        __atomic_store_n(&kernelTLS.preemption_state.enabled, true, __ATOMIC_RELAXED);
     230
     231                        // Signal the compiler that a fence is needed but only for signal handlers
     232                        __atomic_signal_fence(__ATOMIC_RELEASE);
    203233                }
    204234        }
     
    352382
    353383        // Clear sighandler mask before context switching.
     384        #if GCC_VERSION > 50000
    354385        static_assert( sizeof( sigset_t ) == sizeof( cxt->uc_sigmask ), "Expected cxt->uc_sigmask to be of sigset_t" );
     386        #endif
    355387        if ( pthread_sigmask( SIG_SETMASK, (sigset_t *)&(cxt->uc_sigmask), NULL ) == -1 ) {
    356388                abort( "internal error, sigprocmask" );
Note: See TracChangeset for help on using the changeset viewer.