ADTaaron-thesisarm-ehast-experimentalcleanup-dtorsdeferred_resnenumforall-pointer-decayjacob/cs343-translationjenkins-sandboxnew-astnew-ast-unique-exprno_listpersistent-indexerpthread-emulationqualifiedEnum
Last change
on this file since 84b4d607 was
107b01a,
checked in by Thierry Delisle <tdelisle@…>, 6 years ago
|
Several changes to the makefiles
- change .c tests to .cfa
- add require for libtool in configure
- libtoolize to fix some warnings
|
-
Property mode set to
100644
|
File size:
808 bytes
|
Line | |
---|
1 | #include <fstream.hfa> |
---|
2 | #include <kernel.hfa> |
---|
3 | #include <stdlib.hfa> |
---|
4 | #include <thread.hfa> |
---|
5 | |
---|
6 | thread First { semaphore* lock; }; |
---|
7 | thread Second { semaphore* lock; }; |
---|
8 | |
---|
9 | void ?{}( First & this, semaphore & lock ) { ((thread&)this){"Thread 1"}; this.lock = &lock; } |
---|
10 | void ?{}( Second & this, semaphore & lock ) { ((thread&)this){"Thread 2"}; this.lock = &lock; } |
---|
11 | |
---|
12 | void main(First& this) { |
---|
13 | for(int i = 0; i < 10; i++) { |
---|
14 | sout | "First : Suspend No." | i + 1; |
---|
15 | yield(); |
---|
16 | } |
---|
17 | V(*this.lock); |
---|
18 | } |
---|
19 | |
---|
20 | void main(Second& this) { |
---|
21 | P(*this.lock); |
---|
22 | for(int i = 0; i < 10; i++) { |
---|
23 | sout | "Second : Suspend No." | i + 1; |
---|
24 | yield(); |
---|
25 | } |
---|
26 | } |
---|
27 | |
---|
28 | |
---|
29 | int main(int argc, char* argv[]) { |
---|
30 | semaphore lock = { 0 }; |
---|
31 | sout | "User main begin"; |
---|
32 | { |
---|
33 | processor p; |
---|
34 | { |
---|
35 | First f = { lock }; |
---|
36 | Second s = { lock }; |
---|
37 | } |
---|
38 | } |
---|
39 | sout | "User main end"; |
---|
40 | } |
---|
Note: See
TracBrowser
for help on using the repository browser.