source: benchmark/schedint/upp.cc

Last change on this file was 26fd986, checked in by Peter A. Buhr <pabuhr@…>, 4 years ago

update benchmarks for concurrency paper

  • Property mode set to 100644
File size: 613 bytes
RevLine 
[9f0b975]1#include <cstdio>
2
3#include "bench.h"
4
5volatile int go = 0;
6
7_Monitor M {
8        uCondition cond;
9public:
10        void __attribute__((noinline)) call() {
11                cond.signal();
12        }
[26fd986]13        void __attribute__((noinline)) wait() {
[9f0b975]14                go = 1;
[26fd986]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
[9f0b975]24                BENCH(
[26fd986]25                        for ( size_t i = 0; i < times; i++ ) {
26                                m.call();
[9f0b975]27                        },
28                        result
29                )
[b4107c8]30                printf( "%g\n", result );
[9f0b975]31        }
32};
33
[b4107c8]34int main( int argc, char * argv[] ) {
35        BENCH_START()
[9f0b975]36        T t;
[26fd986]37        m.wait();
[dc33b5b]38}
[b4107c8]39
40// Local Variables: //
41// tab-width: 4 //
42// End: //
Note: See TracBrowser for help on using the repository browser.