Ignore:
File:
1 edited

Legend:

Unmodified
Added
Removed
  • src/examples/thread.c

    r60819df7 rbd98b58  
    1 #line 1 "thread.c"
    21#include <fstream>
    3 #include <kernel>
    42#include <stdlib>
    53#include <threads>
     
    1210};
    1311
    14 DECL_THREAD(MyThread)
    15 
    16 void ?{}( MyThread * this ) {
    17 }
     12// DECL_THREAD(MyThread)
    1813
    1914void ?{}( MyThread * this, unsigned id, unsigned count ) {
     
    2217}
    2318
    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();
    2722
    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// }
    3328
    3429int main(int argc, char* argv[]) {
    3530
    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        // }
    4237
    4338        sout | "User main begin" | endl;
    4439
    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        // }
    5244
    5345        sout | "User main end" | endl;
Note: See TracChangeset for help on using the changeset viewer.