Changeset f019069 for libcfa/src/concurrency
- Timestamp:
- May 6, 2019, 10:09:02 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:
- 63364d8
- Parents:
- b9696a8
- Location:
- libcfa/src/concurrency
- Files:
-
- 3 edited
Legend:
- Unmodified
- Added
- Removed
-
libcfa/src/concurrency/CtxSwitch-x86_64.S
rb9696a8 rf019069 100 100 movq %rbp,FP_OFFSET(%rdi) 101 101 102 mfence 103 102 104 // Don't load a new context, directly jump to the desired function 103 104 jmp *%rsi 105 #if defined(PIC) 106 call __suspend_callback@plt 107 #else 108 call __suspend_callback 109 #endif 105 110 .size CtxStore, .-CtxStore 106 111 -
libcfa/src/concurrency/coroutine.cfa
rb9696a8 rf019069 40 40 abort(); 41 41 } 42 43 extern void CtxRet( struct __stack_context_t * to ) asm ("CtxRet") __attribute__ ((__noreturn__)); 42 44 } 43 45 … … 203 205 CoroutineCtxSwitch( src, starter ); 204 206 } 207 208 __attribute__((noreturn)) void __suspend_callback( struct __stack_context_t *, fptr_t call ) { 209 call(); 210 211 coroutine_desc * src = TL_GET( this_thread )->curr_cor; 212 // set state of current coroutine to inactive 213 src->state = src->state == Halted ? Halted : Inactive; 214 215 TL_GET( this_thread )->curr_cor = src->last; 216 217 // context switch to specified coroutine 218 assert( src->last->context.SP ); 219 CtxRet( &src->last->context ); 220 221 abort(); 222 } 205 223 } 206 224 -
libcfa/src/concurrency/coroutine.hfa
rb9696a8 rf019069 68 68 69 69 extern void CtxSwitch( struct __stack_context_t * from, struct __stack_context_t * to ) asm ("CtxSwitch"); 70 extern void CtxStore ( struct __stack_context_t * from, __attribute__((noreturn)) void (*__callback)(void) ) asm ("CtxStore"); 71 extern void CtxRet ( struct __stack_context_t * to ) asm ("CtxRet") __attribute__ ((__noreturn__)); 70 extern void CtxStore ( struct __stack_context_t * from, fptr_t callback ) asm ("CtxStore"); 72 71 } 73 72 … … 172 171 } 173 172 173 __attribute__((noreturn)) void __suspend_callback(void *, fptr_t call); 174 174 175 static inline void suspend_then(fptr_t call) { 175 176 // optimization : read TLS once and reuse it … … 194 195 assert( src->context.SP ); 195 196 196 __attribute__((noreturn)) void __suspend_callback(void) { 197 call(); 198 199 // set state of current coroutine to inactive 200 src->state = src->state == Halted ? Halted : Inactive; 201 202 TL_GET( this_thread )->curr_cor = src->last; 203 204 // context switch to specified coroutine 205 assert( src->last->context.SP ); 206 CtxRet( &src->last->context ); 207 208 abort(); 209 } 210 CtxStore( &src->context, __suspend_callback ); 197 CtxStore( &src->context, call ); 211 198 // when CtxStore returns we are back in the src coroutine 212 199 … … 220 207 return; 221 208 } 222 223 // static inline void suspend_return(void) {224 // // optimization : read TLS once and reuse it225 // // Safety note: this is preemption safe since if226 // // preemption occurs after this line, the pointer227 // // will also migrate which means this value will228 // // stay in syn with the TLS229 // coroutine_desc * src = TL_GET( this_thread )->curr_cor;230 231 // assertf( src->last != 0,232 // "Attempt to suspend coroutine \"%.256s\" (%p) that has never been resumed.\n"233 // "Possible cause is a suspend executed in a member called by a coroutine user rather than by the coroutine main.",234 // src->name, src );235 // assertf( src->last->state != Halted,236 // "Attempt by coroutine \"%.256s\" (%p) to suspend back to terminated coroutine \"%.256s\" (%p).\n"237 // "Possible cause is terminated coroutine's main routine has already returned.",238 // src->name, src, src->last->name, src->last );239 240 // // Safety note : Preemption must be disabled here since kernelTLS.this_coroutine must always be up to date241 // verify( TL_GET( preemption_state.enabled ) || TL_GET( this_processor )->do_terminate );242 // disable_interrupts();243 244 // // set state of current coroutine to inactive245 // src->state = src->state == Halted ? Halted : Inactive;246 247 // // set new coroutine that task is executing248 // kernelTLS.this_coroutine = dst;249 250 // // context switch to specified coroutine251 // assert( src->stack.context );252 // CtxRet( src->stack.context );253 254 // abort();255 // }256 209 257 210 // Local Variables: //
Note: See TracChangeset
for help on using the changeset viewer.