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

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

Added long running test for preempt and reduce short test duration

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