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 0f9bef3 was f80ab45, checked in by Thierry Delisle <tdelisle@…>, 8 years ago |
Internal scheduling tests
|
-
Property mode
set to
100644
|
File size:
977 bytes
|
Line | |
---|
1 | #include <fstream>
|
---|
2 | #include <kernel>
|
---|
3 | #include <monitor>
|
---|
4 | #include <thread>
|
---|
5 |
|
---|
6 | monitor global_t {};
|
---|
7 |
|
---|
8 | global_t globalB;
|
---|
9 | global_t globalA;
|
---|
10 |
|
---|
11 | condition cond;
|
---|
12 |
|
---|
13 | thread Signalee {};
|
---|
14 | thread Signaler {};
|
---|
15 |
|
---|
16 | void signalee_action( global_t * mutex a, global_t * mutex b ) {
|
---|
17 | sout | "Waiting All" | endl;
|
---|
18 | wait( &cond );
|
---|
19 | sout | "Done waiting" | endl;
|
---|
20 | }
|
---|
21 |
|
---|
22 | void main( Signalee* this ) {
|
---|
23 | signalee_action( &globalA, &globalB );
|
---|
24 | }
|
---|
25 |
|
---|
26 | void signaler_action_inner( global_t * mutex a, global_t * mutex b ) {
|
---|
27 | sout | "Entering A & B" | endl;
|
---|
28 | sout | "Signal" | endl;
|
---|
29 | signal( &cond );
|
---|
30 | sout | "Leaving A & B" | endl;
|
---|
31 | }
|
---|
32 |
|
---|
33 | void signaler_action( global_t * mutex a, global_t * b ) {
|
---|
34 | sout | "Entering A" | endl;
|
---|
35 | signaler_action_inner( a, b );
|
---|
36 | sout | "Leaving A" | endl;
|
---|
37 | }
|
---|
38 |
|
---|
39 | void main( Signaler* this ) {
|
---|
40 | for(int i = 0; i < 10_000; i++) {
|
---|
41 | asm volatile ("" : : : "memory");
|
---|
42 | }
|
---|
43 |
|
---|
44 | signaler_action( &globalA, &globalB );
|
---|
45 | }
|
---|
46 |
|
---|
47 | int main(int argc, char* argv[]) {
|
---|
48 | processor p;
|
---|
49 | {
|
---|
50 | Signalee a;
|
---|
51 | Signaler b;
|
---|
52 | }
|
---|
53 | }
|
---|
Note:
See
TracBrowser
for help on using the repository browser.