source: src/tests/sched-int.c @ 2e5ad9f

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 2e5ad9f was f80ab45, checked in by Thierry Delisle <tdelisle@…>, 7 years ago

Internal scheduling tests

  • Property mode set to 100644
File size: 921 bytes
Line 
1#include <fstream>
2#include <kernel>
3#include <monitor>
4#include <thread>
5
6monitor global_t {
7        int value;
8};
9
10global_t global;
11
12condition cond;
13
14thread Signalee {};
15thread Signaler {};
16
17void step1( global_t * mutex this ) {
18        sout | "Step 1" | endl;
19        this->value = 1;
20        wait( &cond );
21}
22
23void step2( global_t * mutex this ) {
24        if( this->value != 1) abort();
25
26        sout | "Step 2" | endl;
27        this->value = 2;
28        signal( &cond );
29}
30
31void step3( global_t * mutex this ) {
32        if( this->value != 2) abort();
33
34        sout | "Step 3" | endl;
35        this->value = 3;
36        signal( &cond );
37}
38
39void main( Signalee* this ) {
40        step1( &global );
41        step3( &global );
42}
43
44void main( Signaler* this ) {
45        for(int i = 0; i < 10_000; i++) {
46                asm volatile ("" : : : "memory");
47        }
48
49        step2( &global );
50}
51
52int main(int argc, char* argv[]) {
53        assert( global.__mon.entry_queue.tail != NULL );
54        processor p;
55        {
56                Signalee a;
57                Signaler b;
58        }
59        if( global.value != 3) abort();
60}
Note: See TracBrowser for help on using the repository browser.