- Timestamp:
- Jan 31, 2022, 1:35:31 PM (3 years ago)
- Branches:
- ADT, ast-experimental, enum, forall-pointer-decay, master, pthread-emulation, qualifiedEnum
- Children:
- d7e9c12
- Parents:
- c9c1c1c
- File:
-
- 1 edited
Legend:
- Unmodified
- Added
- Removed
-
tests/concurrent/preempt.cfa
rc9c1c1c r8e5e945 1 #include <clock.hfa> 1 2 #include <fstream.hfa> 2 3 #include <kernel.hfa> … … 18 19 #else 19 20 static const unsigned long N = 500ul; 21 static volatile Time prev; 22 static Duration preempt_durations[6] = { 0 }; 20 23 #endif 21 24 … … 26 29 thread worker_t { 27 30 int value; 28 unsigned spin;31 unsigned long long spin; 29 32 }; 30 33 … … 36 39 void main(worker_t & this) { 37 40 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 | ")"; 39 42 __cfaabi_check_preemption(); 40 43 if( (counter % 7) == this.value ) { 41 44 __cfaabi_check_preemption(); 45 #if !defined(TEST_LONG) 46 Time now = timeHiRes(); 47 Duration diff = now - prev; 48 prev = now; 49 #endif 42 50 int next = __atomic_add_fetch( &counter, 1, __ATOMIC_SEQ_CST ); 43 51 __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 } 45 62 __cfaabi_check_preemption(); 46 63 this.spin = 0; … … 55 72 processor p; 56 73 { 74 prev = timeHiRes(); 57 75 worker_t w0 = 0; 58 76 worker_t w1 = 1;
Note: See TracChangeset
for help on using the changeset viewer.