Changeset 5c1a531
- Timestamp:
- Apr 11, 2019, 10:36:13 AM (6 years ago)
- Branches:
- ADT, arm-eh, ast-experimental, cleanup-dtors, enum, forall-pointer-decay, jacob/cs343-translation, jenkins-sandbox, master, new-ast, new-ast-unique-expr, pthread-emulation, qualifiedEnum
- Children:
- 3c06bba
- Parents:
- e8e457e
- Location:
- libcfa/src/concurrency
- Files:
-
- 4 edited
Legend:
- Unmodified
- Added
- Removed
-
libcfa/src/concurrency/coroutine.cfa
re8e457e r5c1a531 126 126 // Wrapper for co 127 127 void CoroutineCtxSwitch(coroutine_desc* src, coroutine_desc* dst) { 128 // Safety note : Preemption must be disabled since there is a race condition129 // kernelTLS.this_thread->curr_cor and $rsp/$rbp must agree at all times130 verify( TL_GET( preemption_state.enabled ) || TL_GET( this_processor )->do_terminate );131 disable_interrupts();132 133 128 // set state of current coroutine to inactive 134 129 src->state = src->state == Halted ? Halted : Inactive; … … 144 139 // set state of new coroutine to active 145 140 src->state = Active; 146 147 enable_interrupts( __cfaabi_dbg_ctx );148 verify( TL_GET( preemption_state.enabled ) || TL_GET( this_processor )->do_terminate );149 141 150 142 if( unlikely(src->cancellation != NULL) ) { -
libcfa/src/concurrency/invoke.c
re8e457e r5c1a531 46 46 47 47 cor->state = Active; 48 49 enable_interrupts( __cfaabi_dbg_ctx );50 48 51 49 main( this ); -
libcfa/src/concurrency/invoke.h
re8e457e r5c1a531 65 65 void * SP; 66 66 void * FP; 67 // copy of global UNIX variable errno68 int errno_;69 67 }; 70 68 … … 168 166 // current execution status for coroutine 169 167 enum coroutine_state state; 168 169 //SKULLDUGGERY errno is not save in the thread data structure because returnToKernel appears to be the only function to require saving and restoring it 170 170 171 171 // coroutine body used to store context -
libcfa/src/concurrency/kernel.cfa
re8e457e r5c1a531 91 91 92 92 void ?{}( coroutine_desc & this, current_stack_info_t * info) with( this ) { 93 context.errno_ = 0;94 93 stack.storage = info->storage; 95 94 with(*stack.storage) { … … 237 236 } 238 237 238 static int * __volatile_errno() __attribute__((noinline)); 239 static int * __volatile_errno() { asm(""); return &errno; } 240 239 241 // KERNEL ONLY 240 242 // runThread runs a thread by context switching … … 271 273 thrd_src->state = thrd_src->state == Halted ? Halted : Inactive; 272 274 proc_cor->state = Active; 275 int local_errno = *__volatile_errno(); 273 276 274 277 // set new coroutine that the processor is executing … … 280 283 proc_cor->state = proc_cor->state == Halted ? Halted : Inactive; 281 284 thrd_src->state = Active; 285 *__volatile_errno() = local_errno; 282 286 } 283 287 … … 380 384 src->state = src->state == Halted ? Halted : Inactive; 381 385 382 // SKULLDUGGERY normally interrupts are enable before leaving a coroutine ctxswitch.383 // Therefore, when first creating a coroutine, interrupts are enable before calling the main.384 // This is consistent with thread creation. However, when creating the main processor coroutine,385 // we wan't interrupts to be disabled. Therefore, we double-disable interrupts here so they will386 // stay disabled.387 disable_interrupts();388 389 386 // context switch to specified coroutine 390 387 verify( dst->context.SP );
Note: See TracChangeset
for help on using the changeset viewer.