source: src/tests/sched-ext-dtor.c @ b8116cd

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

Tested and fixed out-of-order waitfor of dtors

  • Property mode set to 100644
File size: 774 bytes
Line 
1//---------------------------------------------------------
2// Barging test
3// Ensures the statement order is reverse when using waitfor ^?{}
4//---------------------------------------------------------
5
6#include <fstream>
7#include <kernel>
8#include <monitor>
9#include <stdlib>
10#include <thread>
11
12#include <stdbool.h>
13
14static const unsigned long N = 5_000ul;
15
16thread dummy_t {};
17
18void ^?{}( dummy_t & mutex this ) {
19        sout | "Dtor" | endl;
20}
21
22void main( dummy_t & this ) {
23        yield(((unsigned)rand48()) % 10);
24        sout | "Main";
25        waitfor( ^?{}, this ) {
26                sout | "After waitfor";
27        }
28        sout | "Ending Main";
29}
30
31int main() {
32        sout | "Starting" | endl;
33        processor p;
34        for( int i = 0; i < N; i++ ){
35                dummy_t dummy;
36                yield( ((unsigned)rand48()) % 100 );
37        }
38        sout | "Stopping" | endl;
39}
Note: See TracBrowser for help on using the repository browser.