ADTaaron-thesisarm-ehast-experimentalcleanup-dtorsdeferred_resndemanglerenumforall-pointer-decayjacob/cs343-translationjenkins-sandboxnew-astnew-ast-unique-exprnew-envno_listpersistent-indexerpthread-emulationqualifiedEnumresolv-newwith_gc
Last change
on this file since 4e9151f was
5ea06d6,
checked in by Thierry Delisle <tdelisle@…>, 7 years ago
|
Prototype of multi monitor internal scheduling
|
-
Property mode set to
100644
|
File size:
827 bytes
|
Line | |
---|
1 | #include <kernel> |
---|
2 | #include <monitor> |
---|
3 | #include <thread> |
---|
4 | |
---|
5 | monitor global_t { |
---|
6 | int value; |
---|
7 | }; |
---|
8 | |
---|
9 | global_t global; |
---|
10 | |
---|
11 | condition cond; |
---|
12 | |
---|
13 | thread Signalee {}; |
---|
14 | thread Signaler {}; |
---|
15 | |
---|
16 | void step1( global_t * mutex this ) { |
---|
17 | this->value = 1; |
---|
18 | wait( &cond ); |
---|
19 | } |
---|
20 | |
---|
21 | void step2( global_t * mutex this ) { |
---|
22 | if( this->value != 1) abort(); |
---|
23 | |
---|
24 | this->value = 2; |
---|
25 | signal( &cond ); |
---|
26 | } |
---|
27 | |
---|
28 | void step3( global_t * mutex this ) { |
---|
29 | if( this->value != 2) abort(); |
---|
30 | |
---|
31 | this->value = 2; |
---|
32 | signal( &cond ); |
---|
33 | } |
---|
34 | |
---|
35 | void main( Signalee* this ) { |
---|
36 | step1( &global ); |
---|
37 | step3( &global ); |
---|
38 | } |
---|
39 | |
---|
40 | void main( Signaler* this ) { |
---|
41 | for(int i = 0; i < 10_000; i++) { |
---|
42 | asm volatile ("" : : : "memory"); |
---|
43 | } |
---|
44 | |
---|
45 | step2( &global ); |
---|
46 | } |
---|
47 | |
---|
48 | int main(int argc, char* argv[]) { |
---|
49 | assert( global.__mon.entry_queue.tail != NULL ); |
---|
50 | processor p; |
---|
51 | { |
---|
52 | Signalee a; |
---|
53 | Signaler b; |
---|
54 | } |
---|
55 | if( global.value != 3) abort(); |
---|
56 | } |
---|
Note: See
TracBrowser
for help on using the repository browser.