source:
benchmark/schedint/cfa2.cfa
@
5ee7d36
Last change on this file since 5ee7d36 was 2316525, checked in by , 4 years ago | |
---|---|
|
|
File size: 660 bytes |
Rev | Line | |
---|---|---|
[73abe95] | 1 | #include <kernel.hfa> |
2 | #include <monitor.hfa> | |
3 | #include <thread.hfa> | |
[9f0b975] | 4 | #include <stdio.h> |
5 | ||
[2316525] | 6 | #include "../bench.h" |
[9f0b975] | 7 | |
8 | volatile int go = 0; | |
9 | condition c; | |
[2316525] | 10 | monitor M {} m1, m2; |
[9f0b975] | 11 | |
[2316525] | 12 | void __attribute__((noinline)) call( M & mutex p1, M & mutex p2 ) { |
13 | signal( c ); | |
[9f0b975] | 14 | } |
15 | ||
[2316525] | 16 | void __attribute__((noinline)) wait( M & mutex p1, M & mutex p2 ) { |
[9f0b975] | 17 | go = 1; |
[2316525] | 18 | for ( times ) { |
19 | wait( c ); | |
20 | } | |
[9f0b975] | 21 | go = 0; |
22 | } | |
23 | ||
24 | thread T {}; | |
[dc33b5b] | 25 | void main( T & ) { |
[2316525] | 26 | while ( go == 0 ) { yield(); } |
27 | BENCH( | |
28 | while ( go == 1 ) { call( m1, m2 ); }, | |
29 | result | |
30 | ) | |
31 | printf( "%g\n", result ); | |
[9f0b975] | 32 | } |
33 | ||
[b4107c8] | 34 | int main( int argc, char * argv[] ) { |
35 | BENCH_START() | |
[9f0b975] | 36 | T t; |
[2316525] | 37 | wait( m1, m2 ); |
[dc33b5b] | 38 | } |
[b4107c8] | 39 | |
40 | // Local Variables: // | |
41 | // tab-width: 4 // | |
42 | // End: // |
Note: See TracBrowser
for help on using the repository browser.