ADT
        ast-experimental
      
      
        
          | 
            Last change
 on this file since e716aec was             26fd986, checked in by Peter A. Buhr <pabuhr@…>, 6 years ago           | 
        
        
          | 
             
update benchmarks for concurrency paper 
 
           | 
        
        
          
            
              - 
Property                 mode
 set to                 
100644
               
             
           | 
        
        
          | 
            File size:
            634 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 | 
 | 
|---|
| 10 | condition c;
 | 
|---|
| 11 | monitor M {} m1;
 | 
|---|
| 12 | 
 | 
|---|
| 13 | void __attribute__((noinline)) call( M & mutex p1 ) {
 | 
|---|
| 14 |         signal( c );
 | 
|---|
| 15 | }
 | 
|---|
| 16 | void __attribute__((noinline)) wait( M & mutex p1 ) {
 | 
|---|
| 17 |         go = 1;
 | 
|---|
| 18 |         for ( times ) {
 | 
|---|
| 19 |                 wait( c );
 | 
|---|
| 20 |         }
 | 
|---|
| 21 | }
 | 
|---|
| 22 | 
 | 
|---|
| 23 | thread T {};
 | 
|---|
| 24 | void main( T & ) {
 | 
|---|
| 25 |         while ( go == 0 ) { yield(); } // waiter must start first
 | 
|---|
| 26 |         BENCH(
 | 
|---|
| 27 |                 for ( times ) { call( m1 ); },
 | 
|---|
| 28 |                 result
 | 
|---|
| 29 |         )
 | 
|---|
| 30 |         printf( "%g\n", result );
 | 
|---|
| 31 | }
 | 
|---|
| 32 | 
 | 
|---|
| 33 | int main( int argc, char * argv[] ) {
 | 
|---|
| 34 |         BENCH_START()
 | 
|---|
| 35 |         T t;
 | 
|---|
| 36 |         wait( m1 );
 | 
|---|
| 37 | }
 | 
|---|
| 38 | 
 | 
|---|
| 39 | // Local Variables: //
 | 
|---|
| 40 | // tab-width: 4 //
 | 
|---|
| 41 | // End: //
 | 
|---|
       
      
  Note:
 See   
TracBrowser
 for help on using the repository browser.