Changeset be73f30


Ignore:
Timestamp:
Nov 5, 2020, 9:44:23 PM (13 months ago)
Author:
Thierry Delisle <tdelisle@…>
Branches:
arm-eh, jacob/cs343-translation, master, new-ast-unique-expr
Children:
3959595
Parents:
e1d6c8d
Message:

Changed many instances of kernelTLS to use active_thread/active_coroutine

Location:
libcfa/src/concurrency
Files:
5 edited

Legend:

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

    re1d6c8d rbe73f30  
    134134void ^?{}($coroutine& this) {
    135135        if(this.state != Halted && this.state != Start && this.state != Primed) {
    136                 $coroutine * src = TL_GET( this_thread )->curr_cor;
     136                $coroutine * src = active_coroutine();
    137137                $coroutine * dst = &this;
    138138
     
    240240
    241241        struct $coroutine * __cfactx_cor_finish(void) {
    242                 struct $coroutine * cor = kernelTLS.this_thread->curr_cor;
     242                struct $coroutine * cor = active_coroutine();
    243243
    244244                if(cor->state == Primed) {
  • libcfa/src/concurrency/coroutine.hfa

    re1d6c8d rbe73f30  
    6363void prime(T & cor);
    6464
    65 static inline struct $coroutine * active_coroutine() { return TL_GET( this_thread )->curr_cor; }
     65static inline struct $coroutine * active_coroutine() { return active_thread()->curr_cor; }
    6666
    6767//-----------------------------------------------------------------------------
     
    8787
    8888        // set new coroutine that task is executing
    89         TL_GET( this_thread )->curr_cor = dst;
     89        active_thread()->curr_cor = dst;
    9090
    9191        // context switch to specified coroutine
     
    112112                // will also migrate which means this value will
    113113                // stay in syn with the TLS
    114                 $coroutine * src = TL_GET( this_thread )->curr_cor;
     114                $coroutine * src = active_coroutine();
    115115
    116116                assertf( src->last != 0,
     
    138138        // will also migrate which means this value will
    139139        // stay in syn with the TLS
    140         $coroutine * src = TL_GET( this_thread )->curr_cor;
     140        $coroutine * src = active_coroutine();
    141141        $coroutine * dst = get_coroutine(cor);
    142142
    143143        if( unlikely(dst->context.SP == 0p) ) {
    144                 TL_GET( this_thread )->curr_cor = dst;
     144                active_thread()->curr_cor = dst;
    145145                __stack_prepare(&dst->stack, 65000);
    146146                __cfactx_start(main, dst, cor, __cfactx_invoke_coroutine);
    147                 TL_GET( this_thread )->curr_cor = src;
     147                active_thread()->curr_cor = src;
    148148        }
    149149
     
    175175        // will also migrate which means this value will
    176176        // stay in syn with the TLS
    177         $coroutine * src = TL_GET( this_thread )->curr_cor;
     177        $coroutine * src = active_coroutine();
    178178
    179179        // not resuming self ?
  • libcfa/src/concurrency/exception.cfa

    re1d6c8d rbe73f30  
    7272        void * stop_param;
    7373
    74         struct $thread * this_thread = TL_GET( this_thread );
     74        struct $thread * this_thread = active_thread();
    7575        if ( &this_thread->self_cor != this_thread->curr_cor ) {
    7676                struct $coroutine * cor = this_thread->curr_cor;
  • libcfa/src/concurrency/locks.cfa

    re1d6c8d rbe73f30  
    7474
    7575void lock( blocking_lock & this ) with( this ) {
     76        $thread * thrd = active_thread();
    7677        lock( lock __cfaabi_dbg_ctx2 );
    77         if ( owner == kernelTLS.this_thread && !multi_acquisition) {
     78        if ( owner == thrd && !multi_acquisition) {
    7879                fprintf(stderr, "A single acquisition lock holder attempted to reacquire the lock resulting in a deadlock."); // Possibly throw instead
    7980                exit(EXIT_FAILURE);
    80         } else if ( owner != 0p && owner != kernelTLS.this_thread ) {
    81                 append( blocked_threads, kernelTLS.this_thread );
     81        } else if ( owner != 0p && owner != thrd ) {
     82                append( blocked_threads, thrd );
    8283                wait_count++;
    8384                unlock( lock );
    8485                park( __cfaabi_dbg_ctx );
    85         } else if ( owner == kernelTLS.this_thread && multi_acquisition ) {
     86        } else if ( owner == thrd && multi_acquisition ) {
    8687                recursion_count++;
    8788                unlock( lock );
    8889        } else {
    89                 owner = kernelTLS.this_thread;
     90                owner = thrd;
    9091                recursion_count = 1;
    9192                unlock( lock );
     
    9495
    9596bool try_lock( blocking_lock & this ) with( this ) {
     97        $thread * thrd = active_thread();
    9698        bool ret = false;
    9799        lock( lock __cfaabi_dbg_ctx2 );
    98100        if ( owner == 0p ) {
    99                 owner = kernelTLS.this_thread;
     101                owner = thrd;
    100102                if ( multi_acquisition ) recursion_count = 1;
    101103                ret = true;
    102         } else if ( owner == kernelTLS.this_thread && multi_acquisition ) {
     104        } else if ( owner == thrd && multi_acquisition ) {
    103105                recursion_count++;
    104106                ret = true;
     
    113115                fprintf( stderr, "There was an attempt to release a lock that isn't held" );
    114116                return;
    115         } else if ( strict_owner && owner != kernelTLS.this_thread ) {
     117        } else if ( strict_owner && owner != active_thread() ) {
    116118                fprintf( stderr, "A thread other than the owner attempted to release an owner lock" );
    117119                return;
     
    159161        if ( owner == 0p ){ // no owner implies lock isn't held
    160162                fprintf( stderr, "A lock that is not held was passed to a synchronization lock" );
    161         } else if ( strict_owner && owner != kernelTLS.this_thread ) {
     163        } else if ( strict_owner && owner != active_thread() ) {
    162164                fprintf( stderr, "A thread other than the owner of a lock passed it to a synchronization lock" );
    163165        } else {
     
    317319
    318320        void wait( synchronization_lock(L) & this ) with(this) {
    319                 info_thread( L ) i = { kernelTLS.this_thread };
     321                info_thread( L ) i = { active_thread() };
    320322                queue_info_thread( this, i );
    321323        }
    322324
    323325        void wait( synchronization_lock(L) & this, uintptr_t info ) with(this) {
    324                 info_thread( L ) i = { kernelTLS.this_thread, info };
     326                info_thread( L ) i = { active_thread(), info };
    325327                queue_info_thread( this, i );
    326328        }
     
    360362
    361363        void wait( synchronization_lock(L) & this, L & l ) with(this) {
    362                 info_thread(L) i = { kernelTLS.this_thread };
     364                info_thread(L) i = { active_thread() };
    363365                queue_info_thread_unlock( this, l, i );
    364366        }
    365367
    366368        void wait( synchronization_lock(L) & this, L & l, uintptr_t info ) with(this) {
    367                 info_thread(L) i = { kernelTLS.this_thread, info };
     369                info_thread(L) i = { active_thread(), info };
    368370                queue_info_thread_unlock( this, l, i );
    369371        }
  • libcfa/src/concurrency/mutex.cfa

    re1d6c8d rbe73f30  
    4040        lock( lock __cfaabi_dbg_ctx2 );
    4141        if( is_locked ) {
    42                 append( blocked_threads, kernelTLS.this_thread );
     42                append( blocked_threads, active_thread() );
    4343                unlock( lock );
    4444                park();
     
    8686        lock( lock __cfaabi_dbg_ctx2 );
    8787        if( owner == 0p ) {
    88                 owner = kernelTLS.this_thread;
     88                owner = active_thread();
    8989                recursion_count = 1;
    9090                unlock( lock );
    9191        }
    92         else if( owner == kernelTLS.this_thread ) {
     92        else if( owner == active_thread() ) {
    9393                recursion_count++;
    9494                unlock( lock );
    9595        }
    9696        else {
    97                 append( blocked_threads, kernelTLS.this_thread );
     97                append( blocked_threads, active_thread() );
    9898                unlock( lock );
    9999                park();
     
    105105        lock( lock __cfaabi_dbg_ctx2 );
    106106        if( owner == 0p ) {
    107                 owner = kernelTLS.this_thread;
     107                owner = active_thread();
    108108                recursion_count = 1;
    109109                ret = true;
    110110        }
    111         else if( owner == kernelTLS.this_thread ) {
     111        else if( owner == active_thread() ) {
    112112                recursion_count++;
    113113                ret = true;
     
    159159void wait(condition_variable & this) {
    160160        lock( this.lock __cfaabi_dbg_ctx2 );
    161         append( this.blocked_threads, kernelTLS.this_thread );
     161        append( this.blocked_threads, active_thread() );
    162162        unlock( this.lock );
    163163        park();
     
    167167void wait(condition_variable & this, L & l) {
    168168        lock( this.lock __cfaabi_dbg_ctx2 );
    169         append( this.blocked_threads, kernelTLS.this_thread );
     169        append( this.blocked_threads, active_thread() );
    170170        unlock(l);
    171171        unlock(this.lock);
Note: See TracChangeset for help on using the changeset viewer.