Changes in / [3febb2d:3959595]
- Location:
- libcfa/src/concurrency
- Files:
-
- 1 deleted
- 5 edited
-
coroutine.cfa (modified) (2 diffs)
-
coroutine.hfa (modified) (5 diffs)
-
exception.cfa (modified) (1 diff)
-
iocall.cfa (deleted)
-
locks.cfa (modified) (8 diffs)
-
mutex.cfa (modified) (5 diffs)
Legend:
- Unmodified
- Added
- Removed
-
libcfa/src/concurrency/coroutine.cfa
r3febb2d r3959595 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
r3febb2d r3959595 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
r3febb2d r3959595 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
r3febb2d r3959595 76 76 77 77 void lock( blocking_lock & this ) with( this ) { 78 $thread * thrd = active_thread(); 78 79 lock( lock __cfaabi_dbg_ctx2 ); 79 if ( owner == kernelTLS.this_thread && !multi_acquisition) {80 if ( owner == thrd && !multi_acquisition) { 80 81 fprintf(stderr, "A single acquisition lock holder attempted to reacquire the lock resulting in a deadlock."); // Possibly throw instead 81 82 exit(EXIT_FAILURE); 82 } else if ( owner != 0p && owner != kernelTLS.this_thread ) {83 append( blocked_threads, kernelTLS.this_thread );83 } else if ( owner != 0p && owner != thrd ) { 84 append( blocked_threads, thrd ); 84 85 wait_count++; 85 86 unlock( lock ); 86 87 park( ); 87 } else if ( owner == kernelTLS.this_thread && multi_acquisition ) {88 } else if ( owner == thrd && multi_acquisition ) { 88 89 recursion_count++; 89 90 unlock( lock ); 90 91 } else { 91 owner = kernelTLS.this_thread;92 owner = thrd; 92 93 recursion_count = 1; 93 94 unlock( lock ); … … 96 97 97 98 bool try_lock( blocking_lock & this ) with( this ) { 99 $thread * thrd = active_thread(); 98 100 bool ret = false; 99 101 lock( lock __cfaabi_dbg_ctx2 ); 100 102 if ( owner == 0p ) { 101 owner = kernelTLS.this_thread;103 owner = thrd; 102 104 if ( multi_acquisition ) recursion_count = 1; 103 105 ret = true; 104 } else if ( owner == kernelTLS.this_thread && multi_acquisition ) {106 } else if ( owner == thrd && multi_acquisition ) { 105 107 recursion_count++; 106 108 ret = true; … … 113 115 lock( lock __cfaabi_dbg_ctx2 ); 114 116 if ( owner == 0p ){ // no owner implies lock isn't held 115 fprintf( stderr, "There was an attempt to release a lock that isn't held" ); 117 fprintf( stderr, "There was an attempt to release a lock that isn't held" ); 116 118 return; 117 } else if ( strict_owner && owner != kernelTLS.this_thread) {118 fprintf( stderr, "A thread other than the owner attempted to release an owner lock" ); 119 } else if ( strict_owner && active_thread() ) { 120 fprintf( stderr, "A thread other than the owner attempted to release an owner lock" ); 119 121 return; 120 122 } … … 163 165 lock( lock __cfaabi_dbg_ctx2 ); 164 166 if ( owner == 0p ){ // no owner implies lock isn't held 165 fprintf( stderr, "A lock that is not held was passed to a synchronization lock" ); 166 } else if ( strict_owner && owner != kernelTLS.this_thread) {167 fprintf( stderr, "A thread other than the owner of a lock passed it to a synchronization lock" ); 167 fprintf( stderr, "A lock that is not held was passed to a synchronization lock" ); 168 } else if ( strict_owner && active_thread() ) { 169 fprintf( stderr, "A thread other than the owner of a lock passed it to a synchronization lock" ); 168 170 } else { 169 171 $thread * thrd = pop_head( blocked_threads ); … … 246 248 unlock( cond->lock ); 247 249 #if !defined( __CFA_NO_STATISTICS__ ) 250 #warning unprotected access to tls TODO discuss this 248 251 kernelTLS.this_stats = copy->t->curr_cluster->stats; 249 252 #endif … … 338 341 remove_( *i.lock ); 339 342 } 340 343 341 344 unlock( lock ); 342 345 park( ); // blocks here … … 374 377 375 378 void wait( condition_variable(L) & this ) with(this) { 376 info_thread( L ) i = { kernelTLS.this_thread};379 info_thread( L ) i = { active_thread() }; 377 380 queue_info_thread( this, i ); 378 381 } 379 382 380 383 void wait( condition_variable(L) & this, uintptr_t info ) with(this) { 381 info_thread( L ) i = { kernelTLS.this_thread, info };384 info_thread( L ) i = { active_thread(), info }; 382 385 queue_info_thread( this, i ); 383 386 } 384 387 385 388 void wait( condition_variable(L) & this, Duration duration ) with(this) { 386 info_thread( L ) i = { kernelTLS.this_thread};389 info_thread( L ) i = { active_thread() }; 387 390 queue_info_thread_timeout(this, i, __kernel_get_time() + duration ); 388 391 } 389 392 390 void wait( condition_variable(L) & this, uintptr_t info, Duration duration ) with(this) { 391 info_thread( L ) i = { kernelTLS.this_thread, info };393 void wait( condition_variable(L) & this, uintptr_t info, Duration duration ) with(this) { 394 info_thread( L ) i = { active_thread(), info }; 392 395 queue_info_thread_timeout(this, i, __kernel_get_time() + duration ); 393 396 } 394 397 395 398 void wait( condition_variable(L) & this, Time time ) with(this) { 396 info_thread( L ) i = { kernelTLS.this_thread};399 info_thread( L ) i = { active_thread() }; 397 400 queue_info_thread_timeout(this, i, time); 398 401 } 399 402 400 403 void wait( condition_variable(L) & this, uintptr_t info, Time time ) with(this) { 401 info_thread( L ) i = { kernelTLS.this_thread, info };404 info_thread( L ) i = { active_thread(), info }; 402 405 queue_info_thread_timeout(this, i, time); 403 406 } 404 407 405 408 void wait( condition_variable(L) & this, L & l ) with(this) { 406 info_thread(L) i = { kernelTLS.this_thread};409 info_thread(L) i = { active_thread() }; 407 410 i.lock = &l; 408 411 queue_info_thread( this, i ); … … 410 413 411 414 void wait( condition_variable(L) & this, L & l, uintptr_t info ) with(this) { 412 info_thread(L) i = { kernelTLS.this_thread, info };415 info_thread(L) i = { active_thread(), info }; 413 416 i.lock = &l; 414 417 queue_info_thread( this, i ); 415 418 } 416 419 417 420 void wait( condition_variable(L) & this, L & l, Duration duration ) with(this) { 418 info_thread(L) i = { kernelTLS.this_thread};421 info_thread(L) i = { active_thread() }; 419 422 i.lock = &l; 420 423 queue_info_thread_timeout(this, i, __kernel_get_time() + duration ); 421 424 } 422 425 423 426 void wait( condition_variable(L) & this, L & l, uintptr_t info, Duration duration ) with(this) { 424 info_thread(L) i = { kernelTLS.this_thread, info };427 info_thread(L) i = { active_thread(), info }; 425 428 i.lock = &l; 426 429 queue_info_thread_timeout(this, i, __kernel_get_time() + duration ); 427 430 } 428 431 429 432 void wait( condition_variable(L) & this, L & l, Time time ) with(this) { 430 info_thread(L) i = { kernelTLS.this_thread};433 info_thread(L) i = { active_thread() }; 431 434 i.lock = &l; 432 435 queue_info_thread_timeout(this, i, time ); 433 436 } 434 437 435 438 void wait( condition_variable(L) & this, L & l, uintptr_t info, Time time ) with(this) { 436 info_thread(L) i = { kernelTLS.this_thread, info };439 info_thread(L) i = { active_thread(), info }; 437 440 i.lock = &l; 438 441 queue_info_thread_timeout(this, i, time ); -
libcfa/src/concurrency/mutex.cfa
r3febb2d r3959595 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.