source: src/tests/sched_internal.c @ 5ea06d6

aaron-thesisarm-ehcleanup-dtorsdeferred_resndemanglerjacob/cs343-translationjenkins-sandboxnew-astnew-ast-unique-exprnew-envno_listpersistent-indexerresolv-newwith_gc
Last change on this file since 5ea06d6 was 5ea06d6, checked in by Thierry Delisle <tdelisle@…>, 5 years ago

Prototype of multi monitor internal scheduling

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