Ignore:
Timestamp:
Feb 1, 2022, 10:10:46 AM (2 years ago)
Author:
Thierry Delisle <tdelisle@…>
Branches:
ADT, ast-experimental, enum, forall-pointer-decay, master, pthread-emulation, qualifiedEnum
Children:
7b2c8c3c
Parents:
f681823 (diff), 89a5a1f (diff)
Note: this is a merge changeset, the changes displayed below correspond to the merge itself.
Use the (diff) links above to see all the changes relative to each parent.
Message:

Merge branch 'master' of plg.uwaterloo.ca:software/cfa/cfa-cc

File:
1 edited

Legend:

Unmodified
Added
Removed
  • tests/concurrent/preempt.cfa

    rf681823 r376c632a  
     1#include <clock.hfa>
    12#include <fstream.hfa>
    23#include <kernel.hfa>
     
    1819#else
    1920static const unsigned long N = 500ul;
     21static volatile Time prev;
     22static Duration preempt_durations[6] = { 0 };
    2023#endif
    2124
     
    2629thread worker_t {
    2730        int value;
    28         unsigned spin;
     31        unsigned long long spin;
    2932};
    3033
     
    3639void main(worker_t & this) {
    3740        while(TEST(counter < N)) {
    38                 if(this.spin > 100_000_000) abort | "Worker" | this.value | "has been spinning too long! (" | this.spin | ")";
     41                if(this.spin > 50_000_000_000) abort | "Worker" | this.value | "has been spinning too long! (" | this.spin | ")";
    3942                __cfaabi_check_preemption();
    4043                if( (counter % 7) == this.value ) {
    4144                        __cfaabi_check_preemption();
     45                        #if !defined(TEST_LONG)
     46                                Time now = timeHiRes();
     47                                Duration diff = now - prev;
     48                                prev = now;
     49                        #endif
    4250                        int next = __atomic_add_fetch( &counter, 1, __ATOMIC_SEQ_CST );
    4351                        __cfaabi_check_preemption();
    44                         if( (next % 100) == 0 ) printf("%d\n", (int)next);
     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                        }
    4562                        __cfaabi_check_preemption();
    4663                        this.spin = 0;
     
    5572        processor p;
    5673        {
     74                prev = timeHiRes();
    5775                worker_t w0 = 0;
    5876                worker_t w1 = 1;
Note: See TracChangeset for help on using the changeset viewer.