Changeset ee897e4b for src/tests/thread.c
- Timestamp:
- Feb 13, 2017, 5:13:11 PM (7 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
- File:
-
- 1 edited
Legend:
- Unmodified
- Added
- Removed
-
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.