source:
benchmark/schedint/upp.cc@
9e1fa35
| Last change on this file since 9e1fa35 was 6e540ea, checked in by , 6 years ago | |
|---|---|
|
|
| File size: 588 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 | } | |
| 13 | ||
| 14 | int __attribute__((noinline)) wait() { | |
| 15 | go = 1; | |
| 16 | BENCH( | |
| [6e540ea] | 17 | for (size_t i = 0; i < times; i++) { |
| [9f0b975] | 18 | cond.wait(); |
| 19 | }, | |
| 20 | result | |
| 21 | ) | |
| [b4107c8] | 22 | printf( "%g\n", result ); |
| [9f0b975] | 23 | go = 0; |
| 24 | return 0; | |
| 25 | } | |
| 26 | }; | |
| 27 | ||
| 28 | M m; | |
| 29 | ||
| 30 | _Task T { | |
| 31 | void main() { | |
| 32 | while(go == 0) { yield(); } | |
| 33 | while(go == 1) { m.call(); } | |
| 34 | ||
| 35 | } | |
| 36 | }; | |
| 37 | ||
| [b4107c8] | 38 | int main( int argc, char * argv[] ) { |
| 39 | BENCH_START() | |
| [9f0b975] | 40 | T t; |
| 41 | return m.wait(); | |
| [dc33b5b] | 42 | } |
| [b4107c8] | 43 | |
| 44 | // Local Variables: // | |
| 45 | // tab-width: 4 // | |
| 46 | // End: // |
Note:
See TracBrowser
for help on using the repository browser.