Changeset f2e40a9f for src/libcfa/concurrency/thread.c
- Timestamp:
- Mar 15, 2017, 9:43:15 PM (9 years ago)
- Branches:
- ADT, aaron-thesis, arm-eh, ast-experimental, cleanup-dtors, deferred_resn, demangler, enum, forall-pointer-decay, jacob/cs343-translation, jenkins-sandbox, master, new-ast, new-ast-unique-expr, new-env, no_list, persistent-indexer, pthread-emulation, qualifiedEnum, resolv-new, with_gc
- Children:
- 27fed7f1, 738e304
- Parents:
- bf4ac09 (diff), 9b443c7f (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. - git-author:
- Peter A. Buhr <pabuhr@…> (03/15/17 21:25:49)
- git-committer:
- Peter A. Buhr <pabuhr@…> (03/15/17 21:43:15)
- File:
-
- 1 moved
Legend:
- Unmodified
- Added
- Removed
-
src/libcfa/concurrency/thread.c
rbf4ac09 rf2e40a9f 6 6 // file "LICENCE" distributed with Cforall. 7 7 // 8 // thread s.c --8 // thread.c -- 9 9 // 10 10 // Author : Thierry Delisle … … 15 15 // 16 16 17 #include "thread s"17 #include "thread" 18 18 19 19 #include "kernel_private.h" … … 28 28 } 29 29 30 extern processor * get_this_processor();30 extern thread_local processor * this_processor; 31 31 32 32 //----------------------------------------------------------------------------- … … 41 41 // Thread ctors and dtors 42 42 43 void ?{}(thread * this) {43 void ?{}(thread_desc* this) { 44 44 (&this->c){}; 45 45 this->c.name = "Anonymous Coroutine"; … … 48 48 } 49 49 50 void ^?{}(thread * this) {50 void ^?{}(thread_desc* this) { 51 51 ^(&this->c){}; 52 52 } … … 74 74 forall( dtype T | is_thread(T) ) 75 75 void start( T* this ) { 76 coroutine * thrd_c = get_coroutine(this);77 thread * thrd_h = get_thread (this);76 coroutine_desc* thrd_c = get_coroutine(this); 77 thread_desc* thrd_h = get_thread (this); 78 78 thrd_c->last = this_coroutine(); 79 get_this_processor()->current_coroutine = thrd_c;79 this_processor->current_coroutine = thrd_c; 80 80 81 81 LIB_DEBUG_PRINTF("Thread start : %p (t %p, c %p)\n", this, thrd_c, thrd_h); … … 94 94 95 95 void yield( void ) { 96 ScheduleInternal( get_this_processor()->current_thread );96 ScheduleInternal( this_processor->current_thread ); 97 97 } 98 98 99 void ThreadCtxSwitch(coroutine * src, coroutine* dst) {99 void ThreadCtxSwitch(coroutine_desc* src, coroutine_desc* dst) { 100 100 // set state of current coroutine to inactive 101 101 src->state = Inactive; … … 107 107 // set new coroutine that the processor is executing 108 108 // and context switch to it 109 get_this_processor()->current_coroutine = dst;109 this_processor->current_coroutine = dst; 110 110 CtxSwitch( src->stack.context, dst->stack.context ); 111 get_this_processor()->current_coroutine = src;111 this_processor->current_coroutine = src; 112 112 113 113 // set state of new coroutine to active … … 116 116 } 117 117 118 // C Helper to signal the termination of a thread 118 // C Helper to signal the termination of a thread_desc 119 119 // Used in invoke.c 120 120 extern "C" { 121 void __thread_signal_termination( thread * this ) {121 void __thread_signal_termination( thread_desc * this ) { 122 122 this->c.state = Halted; 123 123 LIB_DEBUG_PRINTF("Thread end : %p\n", this);
Note:
See TracChangeset
for help on using the changeset viewer.