Ignore:
File:
1 edited

Legend:

Unmodified
Added
Removed
  • src/tests/concurrent/preempt.c

    rb2fe1c9 rb68fc85  
    11#include <kernel>
    22#include <thread>
     3#include <time>
    34
    45#ifndef PREEMPTION_RATE
    5 #define PREEMPTION_RATE 10_000ul
     6#define PREEMPTION_RATE 10`ms
    67#endif
    78
    8 unsigned int default_preemption() {
     9Duration default_preemption() {
    910        return PREEMPTION_RATE;
    1011}
     
    1516static const unsigned long N = 500ul;
    1617#endif
     18
     19extern void __cfaabi_check_preemption();
    1720
    1821static volatile int counter = 0;
     
    2831void main(worker_t & this) {
    2932        while(counter < N) {
     33                __cfaabi_check_preemption();
    3034                if( (counter % 7) == this.value ) {
     35                        __cfaabi_check_preemption();
    3136                        int next = __atomic_add_fetch_4(&counter, 1, __ATOMIC_SEQ_CST);
     37                        __cfaabi_check_preemption();
    3238                        if( (next % 100) == 0 ) printf("%d\n", (int)next);
     39                        __cfaabi_check_preemption();
    3340                }
     41                __cfaabi_check_preemption();
    3442        }
    3543}
Note: See TracChangeset for help on using the changeset viewer.