source: src/tests/monitor.c @ bcda04c

ADTaaron-thesisarm-ehast-experimentalcleanup-dtorsdeferred_resndemanglerenumforall-pointer-decayjacob/cs343-translationjenkins-sandboxnew-astnew-ast-unique-exprnew-envno_listpersistent-indexerpthread-emulationqualifiedEnumresolv-newwith_gc
Last change on this file since bcda04c was bcda04c, checked in by Thierry Delisle <tdelisle@…>, 7 years ago

Fixed autogen constructors for concurrent sues

  • Property mode set to 100644
File size: 776 bytes
Line 
1#include <fstream>
2#include <kernel>
3#include <monitor>
4#include <thread>
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
28struct MyThread { thread_desc __thrd; };
29
30DECL_THREAD(MyThread);
31
32void ?{}( MyThread * this ) {}
33void ^?{}( MyThread * mutex this ) {}
34
35void main( MyThread* this ) {
36        for(int i = 0; i < 1_000_000; i++) {
37                increment( &global );
38        }
39}
40
41int main(int argc, char* argv[]) {
42        assert( global.__mon.entry_queue.tail != NULL );
43        processor p;
44        {
45                scoped(MyThread) f[4];
46        }
47        sout | global.value | endl;
48}
Note: See TracBrowser for help on using the repository browser.