source:
benchmark/schedint/upp.cc
@
df8ba61a
Last change on this file since df8ba61a was 26fd986, checked in by , 5 years ago | |
---|---|
|
|
File size: 613 bytes |
Rev | Line | |
---|---|---|
[9f0b975] | 1 | #include <cstdio> |
2 | ||
3 | #include "bench.h" | |
4 | ||
5 | volatile int go = 0; | |
6 | ||
7 | _Monitor M { | |
8 | uCondition cond; | |
9 | public: | |
10 | void __attribute__((noinline)) call() { | |
11 | cond.signal(); | |
12 | } | |
[26fd986] | 13 | void __attribute__((noinline)) wait() { |
[9f0b975] | 14 | go = 1; |
[26fd986] | 15 | for ( size_t i = 0; i < times; i++ ) { |
16 | cond.wait(); | |
17 | } | |
18 | } | |
19 | } m; | |
20 | ||
21 | _Task T { | |
22 | void main() { | |
23 | while ( go == 0 ) { yield(); } // waiter must start first | |
[9f0b975] | 24 | BENCH( |
[26fd986] | 25 | for ( size_t i = 0; i < times; i++ ) { |
26 | m.call(); | |
[9f0b975] | 27 | }, |
28 | result | |
29 | ) | |
[b4107c8] | 30 | printf( "%g\n", result ); |
[9f0b975] | 31 | } |
32 | }; | |
33 | ||
[b4107c8] | 34 | int main( int argc, char * argv[] ) { |
35 | BENCH_START() | |
[9f0b975] | 36 | T t; |
[26fd986] | 37 | m.wait(); |
[dc33b5b] | 38 | } |
[b4107c8] | 39 | |
40 | // Local Variables: // | |
41 | // tab-width: 4 // | |
42 | // End: // |
Note: See TracBrowser
for help on using the repository browser.