ADTarm-ehast-experimentalenumforall-pointer-decayjacob/cs343-translationnew-astnew-ast-unique-exprpthread-emulationqualifiedEnum
Last change
on this file since 6c4bd02 was
26fd986,
checked in by Peter A. Buhr <pabuhr@…>, 5 years ago
|
update benchmarks for concurrency paper
|
-
Property mode set to
100644
|
File size:
613 bytes
|
Line | |
---|
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 | void __attribute__((noinline)) wait() { |
---|
14 | go = 1; |
---|
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 |
---|
24 | BENCH( |
---|
25 | for ( size_t i = 0; i < times; i++ ) { |
---|
26 | m.call(); |
---|
27 | }, |
---|
28 | result |
---|
29 | ) |
---|
30 | printf( "%g\n", result ); |
---|
31 | } |
---|
32 | }; |
---|
33 | |
---|
34 | int main( int argc, char * argv[] ) { |
---|
35 | BENCH_START() |
---|
36 | T t; |
---|
37 | m.wait(); |
---|
38 | } |
---|
39 | |
---|
40 | // Local Variables: // |
---|
41 | // tab-width: 4 // |
---|
42 | // End: // |
---|
Note: See
TracBrowser
for help on using the repository browser.