source: src/tests/sched-int.c@ 262f085f

ADT aaron-thesis arm-eh ast-experimental cleanup-dtors deferred_resn demangler enum forall-pointer-decay jacob/cs343-translation jenkins-sandbox new-ast new-ast-unique-expr new-env no_list persistent-indexer pthread-emulation qualifiedEnum resolv-new with_gc
Last change on this file since 262f085f was f80ab45, checked in by Thierry Delisle <tdelisle@…>, 8 years ago

Internal scheduling tests

  • Property mode set to 100644
File size: 921 bytes
RevLine 
[f80ab45]1#include <fstream>
[5ea06d6]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 ) {
[f80ab45]18 sout | "Step 1" | endl;
[5ea06d6]19 this->value = 1;
20 wait( &cond );
21}
22
23void step2( global_t * mutex this ) {
24 if( this->value != 1) abort();
25
[f80ab45]26 sout | "Step 2" | endl;
[5ea06d6]27 this->value = 2;
28 signal( &cond );
29}
30
31void step3( global_t * mutex this ) {
32 if( this->value != 2) abort();
33
[f80ab45]34 sout | "Step 3" | endl;
35 this->value = 3;
[5ea06d6]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.