Changeset 60819df7
- Timestamp:
- Jan 24, 2017, 11:45:35 AM (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:
- 2cdf6dc
- Parents:
- 8def349
- File:
-
- 1 edited
Legend:
- Unmodified
- Added
- Removed
-
src/examples/thread.c
r8def349 r60819df7 1 #line 1 "thread.c" 1 2 #include <fstream> 3 #include <kernel> 2 4 #include <stdlib> 3 5 #include <threads> … … 10 12 }; 11 13 12 // DECL_THREAD(MyThread) 14 DECL_THREAD(MyThread) 15 16 void ?{}( MyThread * this ) { 17 } 13 18 14 19 void ?{}( MyThread * this, unsigned id, unsigned count ) { … … 17 22 } 18 23 19 //void main(MyThread* this) {20 //sout | "Thread" | this->id | " : Suspending" | this->count | "times" | endl;21 //yield();24 void main(MyThread* this) { 25 sout | "Thread" | this->id | " : Suspending" | this->count | "times" | endl; 26 yield(); 22 27 23 //for(int i = 0; i < this->count; i++) {24 //sout | "Thread" | this->id | " : Suspend No." | i + 1 | endl;25 //yield();26 //}27 //}28 for(int i = 0; i < this->count; i++) { 29 sout | "Thread" | this->id | " : Suspend No." | i + 1 | endl; 30 yield(); 31 } 32 } 28 33 29 34 int main(int argc, char* argv[]) { 30 35 31 //unsigned itterations = 10u;32 //if(argc == 2) {33 //int val = ato(argv[1]);34 //assert(val >= 0);35 //itterations = val;36 //}36 unsigned itterations = 10u; 37 if(argc == 2) { 38 int val = ato(argv[1]); 39 assert(val >= 0); 40 itterations = val; 41 } 37 42 38 43 sout | "User main begin" | endl; 39 44 40 // { 41 // thread(MyThread) thread1 = { 1u, itterations }; 42 // thread(MyThread) thread2 = { 2u, itterations }; 43 // } 45 { 46 processor p; 47 { 48 thread(MyThread) thread1 = { 1u, itterations }; 49 thread(MyThread) thread2 = { 2u, itterations }; 50 } 51 } 44 52 45 53 sout | "User main end" | endl;
Note: See TracChangeset
for help on using the changeset viewer.