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