source: src/examples/thread.c@ 092528b

ADT aaron-thesis arm-eh ast-experimental cleanup-dtors deferred_resn demangler enum forall-pointer-decay jacob/cs343-translation jenkins-sandbox new-ast new-ast-unique-expr new-env no_list persistent-indexer pthread-emulation qualifiedEnum resolv-new with_gc
Last change on this file since 092528b was bd98b58, checked in by Thierry Delisle <tdelisle@…>, 9 years ago

Kernel now uses intrusive lists and blocking locks for ready queue management.
Update the plan for concurrency.

  • Property mode set to 100644
File size: 910 bytes
RevLine 
[8f49a54]1#include <fstream>
[c49bf54]2#include <stdlib>
3#include <threads>
4
[8f49a54]5// Start coroutine routines
6struct MyThread {
7 thread_h t;
8 unsigned id;
9 unsigned count;
10};
[c49bf54]11
[bd98b58]12// DECL_THREAD(MyThread)
[c49bf54]13
[8f49a54]14void ?{}( MyThread * this, unsigned id, unsigned count ) {
15 this->id = id;
16 this->count = count;
17}
[c49bf54]18
[bd98b58]19// void main(MyThread* this) {
20// sout | "Thread" | this->id | " : Suspending" | this->count | "times" | endl;
21// yield();
[c49bf54]22
[bd98b58]23// for(int i = 0; i < this->count; i++) {
24// sout | "Thread" | this->id | " : Suspend No." | i + 1 | endl;
25// yield();
26// }
27// }
[c84e80a]28
[8f49a54]29int main(int argc, char* argv[]) {
[c49bf54]30
[bd98b58]31 // unsigned itterations = 10u;
32 // if(argc == 2) {
33 // int val = ato(argv[1]);
34 // assert(val >= 0);
35 // itterations = val;
36 // }
[c49bf54]37
[8f49a54]38 sout | "User main begin" | endl;
[c84e80a]39
[bd98b58]40 // {
41 // thread(MyThread) thread1 = { 1u, itterations };
42 // thread(MyThread) thread2 = { 2u, itterations };
43 // }
[c49bf54]44
[8f49a54]45 sout | "User main end" | endl;
[c84e80a]46
[c49bf54]47 return 0;
48}
Note: See TracBrowser for help on using the repository browser.