Changeset 933f32f for libcfa/src/concurrency/thread.cfa
- Timestamp:
- May 24, 2019, 10:19:41 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:
- d908563
- Parents:
- 6a9d4b4 (diff), 292642a (diff)
Note: this is a merge changeset, the changes displayed below correspond to the merge itself.
Use the(diff)
links above to see all the changes relative to each parent. - File:
-
- 1 edited
Legend:
- Unmodified
- Added
- Removed
-
libcfa/src/concurrency/thread.cfa
r6a9d4b4 r933f32f 31 31 // Thread ctors and dtors 32 32 void ?{}(thread_desc & this, const char * const name, cluster & cl, void * storage, size_t storageSize ) with( this ) { 33 context{ NULL, NULL }; 33 34 self_cor{ name, storage, storageSize }; 34 verify(&self_cor);35 state = Start; 35 36 curr_cor = &self_cor; 36 37 self_mon.owner = &this; … … 73 74 forall( dtype T | is_thread(T) ) 74 75 void __thrd_start( T& this ) { 75 coroutine_desc* thrd_c = get_coroutine(this); 76 thread_desc * thrd_h = get_thread (this); 77 thrd_c->last = TL_GET( this_coroutine ); 78 79 // __cfaabi_dbg_print_safe("Thread start : %p (t %p, c %p)\n", this, thrd_c, thrd_h); 76 thread_desc * this_thrd = get_thread(this); 77 thread_desc * curr_thrd = TL_GET( this_thread ); 80 78 81 79 disable_interrupts(); 82 create_stack(&thrd_c->stack, thrd_c->stack.size);83 kernelTLS.this_coroutine = thrd_c;84 80 CtxStart(&this, CtxInvokeThread); 85 assert( thrd_c->last->stack.context ); 86 CtxSwitch( thrd_c->last->stack.context, thrd_c->stack.context ); 81 this_thrd->context.[SP, FP] = this_thrd->self_cor.context.[SP, FP]; 82 verify( this_thrd->context.SP ); 83 CtxSwitch( &curr_thrd->context, &this_thrd->context ); 87 84 88 ScheduleThread(th rd_h);85 ScheduleThread(this_thrd); 89 86 enable_interrupts( __cfaabi_dbg_ctx ); 90 87 } … … 92 89 extern "C" { 93 90 // KERNEL ONLY 94 void __finish_creation(void) { 95 coroutine_desc* thrd_c = kernelTLS.this_coroutine; 96 ThreadCtxSwitch( thrd_c, thrd_c->last ); 91 void __finish_creation(thread_desc * this) { 92 // set new coroutine that the processor is executing 93 // and context switch to it 94 verify( kernelTLS.this_thread != this ); 95 verify( kernelTLS.this_thread->context.SP ); 96 CtxSwitch( &this->context, &kernelTLS.this_thread->context ); 97 97 } 98 98 } … … 112 112 } 113 113 114 // KERNEL ONLY115 void ThreadCtxSwitch(coroutine_desc* src, coroutine_desc* dst) {116 // set state of current coroutine to inactive117 src->state = src->state == Halted ? Halted : Inactive;118 dst->state = Active;119 120 // set new coroutine that the processor is executing121 // and context switch to it122 kernelTLS.this_coroutine = dst;123 assert( src->stack.context );124 CtxSwitch( src->stack.context, dst->stack.context );125 kernelTLS.this_coroutine = src;126 127 // set state of new coroutine to active128 dst->state = dst->state == Halted ? Halted : Inactive;129 src->state = Active;130 }131 132 114 // Local Variables: // 133 115 // mode: c //
Note:
See TracChangeset
for help on using the changeset viewer.