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

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 with_gc
Last change on this file since e93f1d2 was 0f56058, checked in by Peter A. Buhr <pabuhr@…>, 7 years ago

divide "time" into type and functions

  • Property mode set to 100644
File size: 721 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
13static volatile int counter = 0;
14
15thread worker_t {
16 int value;
17};
18
19void ?{}( worker_t & this, int value ) {
20 this.value = value;
21}
22
23void main(worker_t & this) {
24 while(counter < 1000) {
25 if( (counter % 7) == this.value ) {
26 int next = __atomic_add_fetch_4(&counter, 1, __ATOMIC_SEQ_CST);
27 if( (next % 100) == 0 ) printf("%d\n", (int)next);
28 }
29 }
30}
31
32int main(int argc, char* argv[]) {
33 processor p;
34 {
35 worker_t w0 = 0;
36 worker_t w1 = 1;
37 worker_t w2 = 2;
38 worker_t w3 = 3;
39 worker_t w4 = 4;
40 worker_t w5 = 5;
41 worker_t w6 = 6;
42 }
43}
Note: See TracBrowser for help on using the repository browser.