Ignore:
File:
1 edited

Legend:

Unmodified
Added
Removed
  • tests/concurrent/preempt.cfa

    r8e5e945 rb200492  
    1 #include <clock.hfa>
    21#include <fstream.hfa>
    32#include <kernel.hfa>
     
    1918#else
    2019static const unsigned long N = 500ul;
    21 static volatile Time prev;
    22 static Duration preempt_durations[6] = { 0 };
    2320#endif
    2421
     
    2926thread worker_t {
    3027        int value;
    31         unsigned long long spin;
     28        unsigned spin;
    3229};
    3330
     
    3936void main(worker_t & this) {
    4037        while(TEST(counter < N)) {
    41                 if(this.spin > 50_000_000_000) abort | "Worker" | this.value | "has been spinning too long! (" | this.spin | ")";
     38                if(this.spin > 100_000_000) abort | "Worker" | this.value | "has been spinning too long! (" | this.spin | ")";
    4239                __cfaabi_check_preemption();
    4340                if( (counter % 7) == this.value ) {
    4441                        __cfaabi_check_preemption();
    45                         #if !defined(TEST_LONG)
    46                                 Time now = timeHiRes();
    47                                 Duration diff = now - prev;
    48                                 prev = now;
    49                         #endif
    5042                        int next = __atomic_add_fetch( &counter, 1, __ATOMIC_SEQ_CST );
    5143                        __cfaabi_check_preemption();
    52                         if( (next % 100) == 0 ) {
    53                                 #if !defined(TEST_LONG)
    54                                         unsigned idx = next / 100;
    55                                         if (idx >= 6) abort | "Idx from next is invalid: " | idx | "vs" | next;
    56                                         preempt_durations[idx] = diff;
    57                                         if(diff > 12`s) serr | "Duration suspiciously large:" | diff;
    58                                 #endif
    59                                 printf("%d\n", (int)next);
    60 
    61                         }
     44                        if( (next % 100) == 0 ) printf("%d\n", (int)next);
    6245                        __cfaabi_check_preemption();
    6346                        this.spin = 0;
     
    7255        processor p;
    7356        {
    74                 prev = timeHiRes();
    7557                worker_t w0 = 0;
    7658                worker_t w1 = 1;
Note: See TracChangeset for help on using the changeset viewer.