source: src/tests/preempt_longrun/stack.c @ 8ad6533

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 8ad6533 was 8ad6533, checked in by Peter A. Buhr <pabuhr@…>, 6 years ago

remove cfatime.h, move itimerval constructor to "time", update concurrent examples to use Duration

  • Property mode set to 100644
File size: 561 bytes
RevLine 
[cc3e4d0]1#include <kernel>
2#include <thread>
3
4#include <math>
5
6#ifndef PREEMPTION_RATE
[8ad6533]7#define PREEMPTION_RATE 10`ms
[cc3e4d0]8#endif
9
[8ad6533]10Duration default_preemption() {
[cc3e4d0]11        return PREEMPTION_RATE;
12}
13
[0322865c]14thread worker_t {};
[cc3e4d0]15
[1449d83]16void main(worker_t & this) {
[303406a]17        volatile long long p = 5_021_609ul;
18        volatile long long a = 326_417ul;
19        volatile long long n = 1l;
20        for (volatile long long i = 0; i < p; i++) {
[0322865c]21                n *= a;
22                n %= p;
[cc3e4d0]23        }
[0322865c]24
[cc3e4d0]25        if( n != a ) {
26                abort();
27        }
28}
29
[0322865c]30extern "C" {
31static worker_t * workers;
32}
33
[cc3e4d0]34int main(int argc, char* argv[]) {
35        processor p;
36        {
[0322865c]37                worker_t w[7];
38                workers = w;
[cc3e4d0]39        }
[1449d83]40}
Note: See TracBrowser for help on using the repository browser.