source: tests/concurrent/unified_locking/cond_perf.cfa@ cca034e

ADT ast-experimental
Last change on this file since cca034e was 357ab79, checked in by caparsons <caparson@…>, 3 years ago

moved unified locking tests to be under concurrent directory since they probably should have been there this whole time

  • Property mode set to 100644
File size: 1019 bytes
Line 
1#include "locks.hfa"
2
3
4fast_block_lock f;
5fast_cond_var( fast_block_lock ) f_c_f;
6condition_variable( fast_block_lock ) c_f;
7
8unsigned int num_times = 10000;
9
10thread T_F_C_F_WS1 {};
11
12void main( T_F_C_F_WS1 & this ) {
13 for (unsigned int i = 0; i < num_times; i++) {
14 lock(f);
15 if(empty(f_c_f) && i != num_times - 1) {
16 wait(f_c_f,f);
17 }else{
18 notify_one(f_c_f);
19 unlock(f);
20 }
21 }
22}
23
24thread T_C_F_WS1 {};
25
26void main( T_C_F_WS1 & this ) {
27 for (unsigned int i = 0; i < num_times; i++) {
28 lock(f);
29 if(empty(c_f) && i != num_times - 1) {
30 wait(c_f,f);
31 }else{
32 notify_one(c_f);
33 unlock(f);
34 }
35 }
36}
37
38int main(int argc, char* argv[]) {
39 int variation = 0;
40 switch (argc) {
41 case 3:
42 num_times = atoi(argv[2]);
43 case 2:
44 variation = atoi(argv[1]);
45 case 1:
46 break;
47 default:
48 break;
49 }
50 processor p[1];
51
52 if (variation == 0) {
53 T_F_C_F_WS1 t[2];
54 }else if (variation == 1) {
55 T_C_F_WS1 t[2];
56 }
57}
Note: See TracBrowser for help on using the repository browser.