ADT
arm-eh
ast-experimental
enum
forall-pointer-decay
jacob/cs343-translation
jenkins-sandbox
new-ast
new-ast-unique-expr
pthread-emulation
qualifiedEnum
|
Last change
on this file since 09f357ec was 2316525, checked in by Peter A. Buhr <pabuhr@…>, 6 years ago |
|
update benchmarks for concurrency paper
|
-
Property mode
set to
100644
|
|
File size:
660 bytes
|
| Line | |
|---|
| 1 | #include <kernel.hfa>
|
|---|
| 2 | #include <monitor.hfa>
|
|---|
| 3 | #include <thread.hfa>
|
|---|
| 4 | #include <stdio.h>
|
|---|
| 5 |
|
|---|
| 6 | #include "../bench.h"
|
|---|
| 7 |
|
|---|
| 8 | volatile int go = 0;
|
|---|
| 9 | condition c;
|
|---|
| 10 | monitor M {} m1, m2;
|
|---|
| 11 |
|
|---|
| 12 | void __attribute__((noinline)) call( M & mutex p1, M & mutex p2 ) {
|
|---|
| 13 | signal( c );
|
|---|
| 14 | }
|
|---|
| 15 |
|
|---|
| 16 | void __attribute__((noinline)) wait( M & mutex p1, M & mutex p2 ) {
|
|---|
| 17 | go = 1;
|
|---|
| 18 | for ( times ) {
|
|---|
| 19 | wait( c );
|
|---|
| 20 | }
|
|---|
| 21 | go = 0;
|
|---|
| 22 | }
|
|---|
| 23 |
|
|---|
| 24 | thread T {};
|
|---|
| 25 | void main( T & ) {
|
|---|
| 26 | while ( go == 0 ) { yield(); }
|
|---|
| 27 | BENCH(
|
|---|
| 28 | while ( go == 1 ) { call( m1, m2 ); },
|
|---|
| 29 | result
|
|---|
| 30 | )
|
|---|
| 31 | printf( "%g\n", result );
|
|---|
| 32 | }
|
|---|
| 33 |
|
|---|
| 34 | int main( int argc, char * argv[] ) {
|
|---|
| 35 | BENCH_START()
|
|---|
| 36 | T t;
|
|---|
| 37 | wait( m1, m2 );
|
|---|
| 38 | }
|
|---|
| 39 |
|
|---|
| 40 | // Local Variables: //
|
|---|
| 41 | // tab-width: 4 //
|
|---|
| 42 | // End: //
|
|---|
Note:
See
TracBrowser
for help on using the repository browser.