Last change
on this file since 9d3a4cc was
76a8400,
checked in by caparson <caparson@…>, 20 months ago
|
added all cfa benchmarks, contend is the only one used in the thesis, but other may be used later so Im keeping them around
|
-
Property mode set to
100644
|
File size:
1.0 KB
|
Line | |
---|
1 | #include <locks.hfa> |
---|
2 | #include <fstream.hfa> |
---|
3 | #include <stdio.h> |
---|
4 | #include <channel.hfa> |
---|
5 | #include <thread.hfa> |
---|
6 | #include <time.hfa> |
---|
7 | #include <string.h> |
---|
8 | |
---|
9 | size_t total_operations = 0; |
---|
10 | |
---|
11 | // typedef channel_base( int, exp_backoff_then_block_lock ) Channel; |
---|
12 | typedef channel( int ) Channel; |
---|
13 | |
---|
14 | Channel * ping; |
---|
15 | Channel * pong; |
---|
16 | |
---|
17 | bool done = false; |
---|
18 | |
---|
19 | thread Pong {}; |
---|
20 | void main(Pong & this) { |
---|
21 | for ( ;; ) { |
---|
22 | if ( done ) break; |
---|
23 | insert( *ping, 0 ); |
---|
24 | remove( *pong ); |
---|
25 | } |
---|
26 | } |
---|
27 | |
---|
28 | thread Ping {}; |
---|
29 | void main(Ping & this) { |
---|
30 | size_t runs = 0; |
---|
31 | for ( ;; ) { |
---|
32 | if ( done ) break; |
---|
33 | remove( *ping ); |
---|
34 | insert( *pong, 1 ); |
---|
35 | total_operations++; |
---|
36 | } |
---|
37 | } |
---|
38 | |
---|
39 | |
---|
40 | int main( int argc, char * argv[] ) { |
---|
41 | processor proc[1]; |
---|
42 | |
---|
43 | Channel pingChan{ 2 }; |
---|
44 | Channel pongChan{ 2 }; |
---|
45 | |
---|
46 | ping = &pingChan; |
---|
47 | pong = &pongChan; |
---|
48 | |
---|
49 | { |
---|
50 | Ping pi; |
---|
51 | Pong po; |
---|
52 | sleep(10`s); |
---|
53 | done = true; |
---|
54 | insert( *pong, 2 ); |
---|
55 | insert( *ping, 2 ); |
---|
56 | } |
---|
57 | |
---|
58 | sout | total_operations; |
---|
59 | |
---|
60 | // sout | "done"; |
---|
61 | return 0; |
---|
62 | } |
---|
Note: See
TracBrowser
for help on using the repository browser.