- File:
-
- 1 edited
Legend:
- Unmodified
- Added
- Removed
-
libcfa/src/concurrency/coroutine.cfa
r604d77b r212c2187 35 35 36 36 extern "C" { 37 void _CtxCoroutine_Unwind(struct _Unwind_Exception * storage ) __attribute__ ((__noreturn__));37 void _CtxCoroutine_Unwind(struct _Unwind_Exception * storage, struct coroutine_desc *) __attribute__ ((__noreturn__)); 38 38 static void _CtxCoroutine_UnwindCleanup(_Unwind_Reason_Code, struct _Unwind_Exception *) __attribute__ ((__noreturn__)); 39 39 static void _CtxCoroutine_UnwindCleanup(_Unwind_Reason_Code, struct _Unwind_Exception *) { … … 84 84 void ^?{}(coroutine_desc& this) { 85 85 if(this.state != Halted && this.state != Start) { 86 coroutine_desc * src = TL_GET( this_ coroutine );86 coroutine_desc * src = TL_GET( this_thread )->curr_cor; 87 87 coroutine_desc * dst = &this; 88 88 … … 115 115 // Wrapper for co 116 116 void CoroutineCtxSwitch(coroutine_desc* src, coroutine_desc* dst) { 117 // Safety note : This could cause some false positives due to preemption 117 // Safety note : Preemption must be disabled since there is a race condition 118 // kernelTLS.this_thread->curr_cor and $rsp/$rbp must agree at all times 118 119 verify( TL_GET( preemption_state.enabled ) || TL_GET( this_processor )->do_terminate ); 119 120 disable_interrupts(); … … 123 124 124 125 // set new coroutine that task is executing 125 kernelTLS.this_coroutine= dst;126 TL_GET( this_thread )->curr_cor = dst; 126 127 127 128 // context switch to specified coroutine … … 134 135 135 136 enable_interrupts( __cfaabi_dbg_ctx ); 136 // Safety note : This could cause some false positives due to preemption137 137 verify( TL_GET( preemption_state.enabled ) || TL_GET( this_processor )->do_terminate ); 138 138 139 139 140 if( unlikely(src->cancellation != NULL) ) { 140 _CtxCoroutine_Unwind(src->cancellation );141 _CtxCoroutine_Unwind(src->cancellation, src); 141 142 } 142 143 } //ctxSwitchDirect … … 197 198 } 198 199 199 void __leave_coroutine() { 200 coroutine_desc * src = TL_GET( this_coroutine ); // optimization 200 void __leave_coroutine( coroutine_desc * src ) { 201 201 coroutine_desc * starter = src->cancellation != 0 ? src->last : src->starter; 202 202
Note: See TracChangeset
for help on using the changeset viewer.