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