source: tests/concurrent/monitor.cfa @ f8cd310

ADTarm-ehast-experimentalcleanup-dtorsenumforall-pointer-decayjacob/cs343-translationjenkins-sandboxnew-astnew-ast-unique-exprpthread-emulationqualifiedEnum
Last change on this file since f8cd310 was 107b01a, checked in by Thierry Delisle <tdelisle@…>, 5 years ago

Several changes to the makefiles

  • change .c tests to .cfa
  • add require for libtool in configure
  • libtoolize to fix some warnings
  • Property mode set to 100644
File size: 661 bytes
Line 
1#include <fstream.hfa>
2#include <kernel.hfa>
3#include <monitor.hfa>
4#include <thread.hfa>
5
6monitor global_t {
7        int value;
8};
9
10void ?{}(global_t & this) {
11        this.value = 0;
12}
13
14static global_t global;
15
16void increment3( global_t & mutex this ) {
17        this.value += 1;
18}
19
20void increment2( global_t & mutex this ) {
21        increment3( this );
22}
23
24void increment( global_t & mutex this ) {
25        increment2( this );
26}
27
28thread MyThread {};
29
30void main( MyThread & this ) {
31        for(int i = 0; i < 1_000_000; i++) {
32                increment( global );
33        }
34}
35
36int main(int argc, char* argv[]) {
37        assert( global.__mon.entry_queue.tail != NULL );
38        processor p;
39        {
40                MyThread f[4];
41        }
42        sout | global.value;
43}
Note: See TracBrowser for help on using the repository browser.