- File:
-
- 1 edited
-
libcfa/src/concurrency/thread.cfa (modified) (6 diffs)
Legend:
- Unmodified
- Added
- Removed
-
libcfa/src/concurrency/thread.cfa
rb798713 r5b2b42e 10 10 // Created On : Tue Jan 17 12:27:26 2017 11 11 // Last Modified By : Peter A. Buhr 12 // Last Modified On : Fri Mar 30 17:19:52 201813 // Update Count : 812 // Last Modified On : Wed Dec 4 09:17:49 2019 13 // Update Count : 9 14 14 // 15 15 … … 33 33 // Thread ctors and dtors 34 34 void ?{}(thread_desc & this, const char * const name, cluster & cl, void * storage, size_t storageSize ) with( this ) { 35 context{ NULL, NULL};35 context{ 0p, 0p }; 36 36 self_cor{ name, storage, storageSize }; 37 37 state = Start; … … 41 41 self_mon_p = &self_mon; 42 42 curr_cluster = &cl; 43 link.next = 0p; 44 link.prev = 0p; 43 next = 0p; 45 44 46 node.next = NULL;47 node.prev = NULL;45 node.next = 0p; 46 node.prev = 0p; 48 47 doregister(curr_cluster, this); 49 48 … … 59 58 void ?{}( scoped(T)& this ) with( this ) { 60 59 handle{}; 61 __thrd_start(handle );60 __thrd_start(handle, main); 62 61 } 63 62 … … 65 64 void ?{}( scoped(T)& this, P params ) with( this ) { 66 65 handle{ params }; 67 __thrd_start(handle );66 __thrd_start(handle, main); 68 67 } 69 68 … … 76 75 // Starting and stopping threads 77 76 forall( dtype T | is_thread(T) ) 78 void __thrd_start( T & this) {77 void __thrd_start( T & this, void (*main_p)(T &) ) { 79 78 thread_desc * this_thrd = get_thread(this); 80 thread_desc * curr_thrd = TL_GET( this_thread );81 79 82 80 disable_interrupts(); 83 CtxStart(&this, CtxInvokeThread); 81 CtxStart(main_p, get_coroutine(this), this, CtxInvokeThread); 82 84 83 this_thrd->context.[SP, FP] = this_thrd->self_cor.context.[SP, FP]; 85 84 verify( this_thrd->context.SP ); 86 CtxSwitch( &curr_thrd->context, &this_thrd->context );87 85 88 86 ScheduleThread(this_thrd); 89 87 enable_interrupts( __cfaabi_dbg_ctx ); 90 }91 92 extern "C" {93 // KERNEL ONLY94 void __finish_creation(thread_desc * this) {95 // set new coroutine that the processor is executing96 // and context switch to it97 verify( kernelTLS.this_thread != this );98 verify( kernelTLS.this_thread->context.SP );99 CtxSwitch( &this->context, &kernelTLS.this_thread->context );100 }101 88 } 102 89
Note:
See TracChangeset
for help on using the changeset viewer.