source: src/tests/concurrent/preempt.c @ de6319f

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

Merge branch 'master' of plg.uwaterloo.ca:software/cfa/cfa-cc

  • Property mode set to 100644
File size: 828 bytes
Line 
1#include <kernel>
2#include <thread>
3#include <time>
4
5#ifndef PREEMPTION_RATE
6#define PREEMPTION_RATE 10`ms
7#endif
8
9Duration default_preemption() {
10        return PREEMPTION_RATE;
11}
12
13#ifdef LONG_TEST
14static const unsigned long N = 30_000ul;
15#else
16static const unsigned long N = 500ul;
17#endif
18
19static volatile int counter = 0;
20
21thread worker_t {
22        int value;
23};
24
25void ?{}( worker_t & this, int value ) {
26        this.value = value;
27}
28
29void main(worker_t & this) {
30        while(counter < N) {
31                if( (counter % 7) == this.value ) {
32                        int next = __atomic_add_fetch_4(&counter, 1, __ATOMIC_SEQ_CST);
33                        if( (next % 100) == 0 ) printf("%d\n", (int)next);
34                }
35        }
36}
37
38int main(int argc, char* argv[]) {
39        processor p;
40        {
41                worker_t w0 = 0;
42                worker_t w1 = 1;
43                worker_t w2 = 2;
44                worker_t w3 = 3;
45                worker_t w4 = 4;
46                worker_t w5 = 5;
47                worker_t w6 = 6;
48        }
49}
Note: See TracBrowser for help on using the repository browser.