- Timestamp:
- Nov 5, 2020, 9:44:23 PM (4 years ago)
- Branches:
- ADT, arm-eh, ast-experimental, enum, forall-pointer-decay, jacob/cs343-translation, master, new-ast-unique-expr, pthread-emulation, qualifiedEnum
- Children:
- 3959595
- Parents:
- e1d6c8dd
- Location:
- libcfa/src/concurrency
- Files:
-
- 5 edited
Legend:
- Unmodified
- Added
- Removed
-
libcfa/src/concurrency/coroutine.cfa
re1d6c8dd rbe73f30 134 134 void ^?{}($coroutine& this) { 135 135 if(this.state != Halted && this.state != Start && this.state != Primed) { 136 $coroutine * src = TL_GET( this_thread )->curr_cor;136 $coroutine * src = active_coroutine(); 137 137 $coroutine * dst = &this; 138 138 … … 240 240 241 241 struct $coroutine * __cfactx_cor_finish(void) { 242 struct $coroutine * cor = kernelTLS.this_thread->curr_cor;242 struct $coroutine * cor = active_coroutine(); 243 243 244 244 if(cor->state == Primed) { -
libcfa/src/concurrency/coroutine.hfa
re1d6c8dd rbe73f30 63 63 void prime(T & cor); 64 64 65 static inline struct $coroutine * active_coroutine() { return TL_GET( this_thread)->curr_cor; }65 static inline struct $coroutine * active_coroutine() { return active_thread()->curr_cor; } 66 66 67 67 //----------------------------------------------------------------------------- … … 87 87 88 88 // set new coroutine that task is executing 89 TL_GET( this_thread)->curr_cor = dst;89 active_thread()->curr_cor = dst; 90 90 91 91 // context switch to specified coroutine … … 112 112 // will also migrate which means this value will 113 113 // stay in syn with the TLS 114 $coroutine * src = TL_GET( this_thread )->curr_cor;114 $coroutine * src = active_coroutine(); 115 115 116 116 assertf( src->last != 0, … … 138 138 // will also migrate which means this value will 139 139 // stay in syn with the TLS 140 $coroutine * src = TL_GET( this_thread )->curr_cor;140 $coroutine * src = active_coroutine(); 141 141 $coroutine * dst = get_coroutine(cor); 142 142 143 143 if( unlikely(dst->context.SP == 0p) ) { 144 TL_GET( this_thread)->curr_cor = dst;144 active_thread()->curr_cor = dst; 145 145 __stack_prepare(&dst->stack, 65000); 146 146 __cfactx_start(main, dst, cor, __cfactx_invoke_coroutine); 147 TL_GET( this_thread)->curr_cor = src;147 active_thread()->curr_cor = src; 148 148 } 149 149 … … 175 175 // will also migrate which means this value will 176 176 // stay in syn with the TLS 177 $coroutine * src = TL_GET( this_thread )->curr_cor;177 $coroutine * src = active_coroutine(); 178 178 179 179 // not resuming self ? -
libcfa/src/concurrency/exception.cfa
re1d6c8dd rbe73f30 72 72 void * stop_param; 73 73 74 struct $thread * this_thread = TL_GET( this_thread);74 struct $thread * this_thread = active_thread(); 75 75 if ( &this_thread->self_cor != this_thread->curr_cor ) { 76 76 struct $coroutine * cor = this_thread->curr_cor; -
libcfa/src/concurrency/locks.cfa
re1d6c8dd rbe73f30 74 74 75 75 void lock( blocking_lock & this ) with( this ) { 76 $thread * thrd = active_thread(); 76 77 lock( lock __cfaabi_dbg_ctx2 ); 77 if ( owner == kernelTLS.this_thread && !multi_acquisition) {78 if ( owner == thrd && !multi_acquisition) { 78 79 fprintf(stderr, "A single acquisition lock holder attempted to reacquire the lock resulting in a deadlock."); // Possibly throw instead 79 80 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 ); 82 83 wait_count++; 83 84 unlock( lock ); 84 85 park( __cfaabi_dbg_ctx ); 85 } else if ( owner == kernelTLS.this_thread && multi_acquisition ) {86 } else if ( owner == thrd && multi_acquisition ) { 86 87 recursion_count++; 87 88 unlock( lock ); 88 89 } else { 89 owner = kernelTLS.this_thread;90 owner = thrd; 90 91 recursion_count = 1; 91 92 unlock( lock ); … … 94 95 95 96 bool try_lock( blocking_lock & this ) with( this ) { 97 $thread * thrd = active_thread(); 96 98 bool ret = false; 97 99 lock( lock __cfaabi_dbg_ctx2 ); 98 100 if ( owner == 0p ) { 99 owner = kernelTLS.this_thread;101 owner = thrd; 100 102 if ( multi_acquisition ) recursion_count = 1; 101 103 ret = true; 102 } else if ( owner == kernelTLS.this_thread && multi_acquisition ) {104 } else if ( owner == thrd && multi_acquisition ) { 103 105 recursion_count++; 104 106 ret = true; … … 113 115 fprintf( stderr, "There was an attempt to release a lock that isn't held" ); 114 116 return; 115 } else if ( strict_owner && owner != kernelTLS.this_thread) {117 } else if ( strict_owner && owner != active_thread() ) { 116 118 fprintf( stderr, "A thread other than the owner attempted to release an owner lock" ); 117 119 return; … … 159 161 if ( owner == 0p ){ // no owner implies lock isn't held 160 162 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() ) { 162 164 fprintf( stderr, "A thread other than the owner of a lock passed it to a synchronization lock" ); 163 165 } else { … … 317 319 318 320 void wait( synchronization_lock(L) & this ) with(this) { 319 info_thread( L ) i = { kernelTLS.this_thread};321 info_thread( L ) i = { active_thread() }; 320 322 queue_info_thread( this, i ); 321 323 } 322 324 323 325 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 }; 325 327 queue_info_thread( this, i ); 326 328 } … … 360 362 361 363 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() }; 363 365 queue_info_thread_unlock( this, l, i ); 364 366 } 365 367 366 368 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 }; 368 370 queue_info_thread_unlock( this, l, i ); 369 371 } -
libcfa/src/concurrency/mutex.cfa
re1d6c8dd rbe73f30 40 40 lock( lock __cfaabi_dbg_ctx2 ); 41 41 if( is_locked ) { 42 append( blocked_threads, kernelTLS.this_thread);42 append( blocked_threads, active_thread() ); 43 43 unlock( lock ); 44 44 park(); … … 86 86 lock( lock __cfaabi_dbg_ctx2 ); 87 87 if( owner == 0p ) { 88 owner = kernelTLS.this_thread;88 owner = active_thread(); 89 89 recursion_count = 1; 90 90 unlock( lock ); 91 91 } 92 else if( owner == kernelTLS.this_thread) {92 else if( owner == active_thread() ) { 93 93 recursion_count++; 94 94 unlock( lock ); 95 95 } 96 96 else { 97 append( blocked_threads, kernelTLS.this_thread);97 append( blocked_threads, active_thread() ); 98 98 unlock( lock ); 99 99 park(); … … 105 105 lock( lock __cfaabi_dbg_ctx2 ); 106 106 if( owner == 0p ) { 107 owner = kernelTLS.this_thread;107 owner = active_thread(); 108 108 recursion_count = 1; 109 109 ret = true; 110 110 } 111 else if( owner == kernelTLS.this_thread) {111 else if( owner == active_thread() ) { 112 112 recursion_count++; 113 113 ret = true; … … 159 159 void wait(condition_variable & this) { 160 160 lock( this.lock __cfaabi_dbg_ctx2 ); 161 append( this.blocked_threads, kernelTLS.this_thread);161 append( this.blocked_threads, active_thread() ); 162 162 unlock( this.lock ); 163 163 park(); … … 167 167 void wait(condition_variable & this, L & l) { 168 168 lock( this.lock __cfaabi_dbg_ctx2 ); 169 append( this.blocked_threads, kernelTLS.this_thread);169 append( this.blocked_threads, active_thread() ); 170 170 unlock(l); 171 171 unlock(this.lock);
Note: See TracChangeset
for help on using the changeset viewer.