Changeset afd550c


Ignore:
Timestamp:
May 8, 2018, 5:22:38 PM (3 years ago)
Author:
Thierry Delisle <tdelisle@…>
Branches:
aaron-thesis, arm-eh, cleanup-dtors, deferred_resn, demangler, jacob/cs343-translation, jenkins-sandbox, master, new-ast, new-ast-unique-expr, new-env, no_list, persistent-indexer, with_gc
Children:
b4a835d, de94a60
Parents:
4990812
Message:

Some more work on TLS macros

Location:
src/libcfa/concurrency
Files:
7 edited

Legend:

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

    r4990812 rafd550c  
    8585void CoroutineCtxSwitch(coroutine_desc* src, coroutine_desc* dst) {
    8686      // Safety note : This could cause some false positives due to preemption
    87       verify( TL_GET( preemption_state ).enabled || TL_GET( this_processor )->do_terminate );
     87      verify( TL_GET( preemption_state.enabled ) || TL_GET( this_processor )->do_terminate );
    8888      disable_interrupts();
    8989
     
    104104      enable_interrupts( __cfaabi_dbg_ctx );
    105105      // Safety note : This could cause some false positives due to preemption
    106       verify( TL_GET( preemption_state ).enabled || TL_GET( this_processor )->do_terminate );
     106      verify( TL_GET( preemption_state.enabled ) || TL_GET( this_processor )->do_terminate );
    107107} //ctxSwitchDirect
    108108
  • src/libcfa/concurrency/invoke.c

    r4990812 rafd550c  
    6969        // Fetch the thread handle from the user defined thread structure
    7070        struct thread_desc* thrd = get_thread( this );
     71        thrd->self_cor.last = NULL;
    7172
    7273        // Officially start the thread by enabling preemption
  • src/libcfa/concurrency/invoke.h

    r4990812 rafd550c  
    4949        static inline struct coroutine_desc * volatile active_coroutine() { return TL_GET( this_coroutine ); }
    5050        static inline struct thread_desc    * volatile active_thread   () { return TL_GET( this_thread    ); }
    51         // static inline struct processor      * volatile active_processor() { return TL_GET( this_processor ); } // UNSAFE
     51        static inline struct processor      * volatile active_processor() { return TL_GET( this_processor ); } // UNSAFE
    5252        #endif
    5353
  • src/libcfa/concurrency/kernel.c

    r4990812 rafd550c  
    422422        }
    423423
    424         verify( ! preemption_state.enabled );
     424        verify( ! kernelTLS.preemption_state.enabled );
    425425        returnToKernel();
    426         verify( ! preemption_state.enabled );
     426        verify( ! kernelTLS.preemption_state.enabled );
    427427
    428428        enable_interrupts( __cfaabi_dbg_ctx );
     
    578578        verify( ! kernelTLS.preemption_state.enabled );
    579579        enable_interrupts( __cfaabi_dbg_ctx );
    580         verify( TL_GET( preemption_state ).enabled );
     580        verify( TL_GET( preemption_state.enabled ) );
    581581}
    582582
     
    584584        __cfaabi_dbg_print_safe("\n--------------------------------------------------\nKernel : Shutting down\n");
    585585
    586         verify( TL_GET( preemption_state ).enabled );
     586        verify( TL_GET( preemption_state.enabled ) );
    587587        disable_interrupts();
    588588        verify( ! kernelTLS.preemption_state.enabled );
     
    642642static bool kernel_abort_called = false;
    643643
    644 void * kernel_abort    (void) __attribute__ ((__nothrow__)) {
     644void * kernel_abort(void) __attribute__ ((__nothrow__)) {
    645645        // abort cannot be recursively entered by the same or different processors because all signal handlers return when
    646646        // the globalAbort flag is true.
  • src/libcfa/concurrency/monitor.c

    r4990812 rafd550c  
    480480
    481481        // Create the node specific to this wait operation
    482         wait_ctx_primed( TL_GET( this_thread ), 0 )
     482        wait_ctx_primed( kernelTLS.this_thread, 0 )
    483483
    484484        //save contexts
  • src/libcfa/concurrency/preemption.c

    r4990812 rafd550c  
    149149        // Disable interrupts by incrementing the counter
    150150        void disable_interrupts() {
    151                 with( TL_GET( preemption_state ) ) {
     151                with( kernelTLS.preemption_state ) {
    152152                        enabled = false;
    153153                        __attribute__((unused)) unsigned short new_val = disable_count + 1;
     
    160160        // If counter reaches 0, execute any pending CtxSwitch
    161161        void enable_interrupts( __cfaabi_dbg_ctx_param ) {
    162                 processor   * proc = TL_GET( this_processor ); // Cache the processor now since interrupts can start happening after the atomic add
    163                 thread_desc * thrd = TL_GET( this_thread );       // Cache the thread now since interrupts can start happening after the atomic add
    164 
    165                 with( TL_GET( preemption_state ) ){
     162                processor   * proc = kernelTLS.this_processor; // Cache the processor now since interrupts can start happening after the atomic add
     163                thread_desc * thrd = kernelTLS.this_thread;       // Cache the thread now since interrupts can start happening after the atomic add
     164
     165                with( kernelTLS.preemption_state ){
    166166                        unsigned short prev = disable_count;
    167167                        disable_count -= 1;
     
    185185        // Don't execute any pending CtxSwitch even if counter reaches 0
    186186        void enable_interrupts_noPoll() {
    187                 unsigned short prev = TL_GET( preemption_state ).disable_count;
    188                 TL_GET( preemption_state ).disable_count -= 1;
     187                unsigned short prev = kernelTLS.preemption_state.disable_count;
     188                kernelTLS.preemption_state.disable_count -= 1;
    189189                verifyf( prev != 0u, "Incremented from %u\n", prev );                     // If this triggers someone is enabled already enabled interrupts
    190190                if( prev == 1 ) {
    191                         TL_GET( preemption_state ).enabled = true;
     191                        kernelTLS.preemption_state.enabled = true;
    192192                }
    193193        }
  • src/libcfa/concurrency/thread.c

    r4990812 rafd550c  
    100100void yield( void ) {
    101101        // Safety note : This could cause some false positives due to preemption
    102       verify( TL_GET( preemption_state ).enabled );
     102      verify( TL_GET( preemption_state.enabled ) );
    103103        BlockInternal( TL_GET( this_thread ) );
    104104        // Safety note : This could cause some false positives due to preemption
    105       verify( TL_GET( preemption_state ).enabled );
     105      verify( TL_GET( preemption_state.enabled ) );
    106106}
    107107
Note: See TracChangeset for help on using the changeset viewer.