- Timestamp:
- Feb 13, 2017, 5:13:11 PM (8 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:
- eafb094
- Parents:
- db6f06a
- Location:
- src
- Files:
-
- 7 edited
Legend:
- Unmodified
- Added
- Removed
-
TabularUnified src/libcfa/concurrency/coroutines ¶
rdb6f06a ree897e4b 77 77 "Possible cause is a suspend executed in a member called by a coroutine user rather than by the coroutine main.", 78 78 src->name, src ); 79 assertf( src->last-> notHalted,79 assertf( src->last->state != Halted, 80 80 "Attempt by coroutine \"%.256s\" (%p) to suspend back to terminated coroutine \"%.256s\" (%p).\n" 81 81 "Possible cause is terminated coroutine's main routine has already returned.", … … 98 98 // not resuming self ? 99 99 if ( src != dst ) { 100 assertf( dst-> notHalted ,100 assertf( dst->state != Halted , 101 101 "Attempt by coroutine %.256s (%p) to resume terminated coroutine %.256s (%p).\n" 102 102 "Possible cause is terminated coroutine's main routine has already returned.", … … 116 116 // not resuming self ? 117 117 if ( src != dst ) { 118 assertf( dst-> notHalted ,118 assertf( dst->state != Halted , 119 119 "Attempt by coroutine %.256s (%p) to resume terminated coroutine %.256s (%p).\n" 120 120 "Possible cause is terminated coroutine's main routine has already returned.", -
TabularUnified src/libcfa/concurrency/coroutines.c ¶
rdb6f06a ree897e4b 68 68 this->errno_ = 0; 69 69 this->state = Start; 70 this->notHalted = true;71 70 this->starter = NULL; 72 71 this->last = NULL; -
TabularUnified src/libcfa/concurrency/invoke.c ¶
rdb6f06a ree897e4b 48 48 main( this ); 49 49 50 cor->state = Halt; 51 cor->notHalted = false; 50 cor->state = Halted; 52 51 53 52 //Final suspend, should never return -
TabularUnified src/libcfa/concurrency/invoke.h ¶
rdb6f06a ree897e4b 39 39 }; 40 40 41 // struct simple_lock {42 // struct simple_thread_list blocked;43 // };44 45 41 struct signal_once { 46 42 volatile bool condition; … … 54 50 void append( struct simple_thread_list *, struct thread * ); 55 51 struct thread * pop_head( struct simple_thread_list * ); 56 57 // void ?{}(simple_lock * this);58 // void ^?{}(simple_lock * this);59 52 60 53 void ?{}(spinlock * this); … … 76 69 }; 77 70 78 enum coroutine_state { Start, Inactive, Active, Halt, Primed };71 enum coroutine_state { Halted, Start, Inactive, Active, Primed }; 79 72 80 73 struct coroutine { … … 83 76 int errno_; // copy of global UNIX variable errno 84 77 enum coroutine_state state; // current execution status for coroutine 85 bool notHalted; // indicate if execuation state is not halted86 78 struct coroutine *starter; // first coroutine to resume this one 87 79 struct coroutine *last; // last coroutine to resume this one … … 89 81 90 82 struct thread { 91 struct coroutine c; 92 s ignal_once terminated;// indicate if execuation state is not halted93 struct thread * next; 83 struct coroutine c; // coroutine body used to store context 84 struct signal_once terminated;// indicate if execuation state is not halted 85 struct thread * next; // instrusive link field for threads 94 86 }; 95 87 -
TabularUnified src/libcfa/concurrency/kernel.c ¶
rdb6f06a ree897e4b 119 119 this->name = "Main Thread"; 120 120 this->errno_ = 0; 121 this->state = Inactive; 122 this->notHalted = true; 121 this->state = Start; 123 122 } 124 123 … … 287 286 proc_cor_storage.c.state = Active; 288 287 main( &proc_cor_storage ); 289 proc_cor_storage.c.state = Halt; 290 proc_cor_storage.c.notHalted = false; 288 proc_cor_storage.c.state = Halted; 291 289 292 290 // Main routine of the core returned, the core is now fully terminated -
TabularUnified src/libcfa/concurrency/threads.c ¶
rdb6f06a ree897e4b 120 120 extern "C" { 121 121 void __thread_signal_termination( thread * this ) { 122 this->c.state = Halt ;122 this->c.state = Halted; 123 123 LIB_DEBUG_PRINTF("Thread end : %p\n", this); 124 124 signal( &this->terminated ); -
TabularUnified src/tests/thread.c ¶
rdb6f06a ree897e4b 4 4 #include <threads> 5 5 6 struct First { thread t; si mple_lock* lock; };7 struct Second { thread t; si mple_lock* lock; };6 struct First { thread t; signal_once* lock; }; 7 struct Second { thread t; signal_once* lock; }; 8 8 9 9 DECL_THREAD(First); 10 10 DECL_THREAD(Second); 11 11 12 void ?{}( First * this, si mple_lock* lock ) { this->lock = lock; }13 void ?{}( Second * this, si mple_lock* lock ) { this->lock = lock; }12 void ?{}( First * this, signal_once* lock ) { this->lock = lock; } 13 void ?{}( Second * this, signal_once* lock ) { this->lock = lock; } 14 14 15 15 void main(First* this) { … … 18 18 yield(); 19 19 } 20 unlock(this->lock);20 signal(this->lock); 21 21 } 22 22 23 23 void main(Second* this) { 24 lock(this->lock);24 wait(this->lock); 25 25 for(int i = 0; i < 10; i++) { 26 26 sout | "Second : Suspend No." | i + 1 | endl; … … 31 31 32 32 int main(int argc, char* argv[]) { 33 si mple_locklock;33 signal_once lock; 34 34 sout | "User main begin" | endl; 35 35 { 36 //processor p;36 processor p; 37 37 { 38 38 scoped(First) f = { &lock };
Note: See TracChangeset
for help on using the changeset viewer.