Changeset 7b2c8c3c


Ignore:
Timestamp:
Feb 1, 2022, 10:32:00 AM (12 months ago)
Author:
Thierry Delisle <tdelisle@…>
Branches:
enum, forall-pointer-decay, master, pthread-emulation, qualifiedEnum
Children:
34c32f0, fc72696c
Parents:
376c632a
Message:

Moved globals to a struct so maybe gcc won't just optimize out my debug information.

File:
1 edited

Legend:

Unmodified
Added
Removed
  • tests/concurrent/preempt.cfa

    r376c632a r7b2c8c3c  
    1919#else
    2020static const unsigned long N = 500ul;
    21 static volatile Time prev;
    22 static Duration preempt_durations[6] = { 0 };
    2321#endif
    2422
    2523extern void __cfaabi_check_preemption();
    2624
    27 static volatile int counter = 0;
     25static struct {
     26        volatile int counter;
     27        volatile Time prev;
     28        Duration durations[6];
     29} globals;
    2830
    2931thread worker_t {
     
    3840
    3941void main(worker_t & this) {
    40         while(TEST(counter < N)) {
     42        while(TEST(globals.counter < N)) {
    4143                if(this.spin > 50_000_000_000) abort | "Worker" | this.value | "has been spinning too long! (" | this.spin | ")";
    4244                __cfaabi_check_preemption();
    43                 if( (counter % 7) == this.value ) {
     45                if( (globals.counter % 7) == this.value ) {
    4446                        __cfaabi_check_preemption();
    4547                        #if !defined(TEST_LONG)
    4648                                Time now = timeHiRes();
    47                                 Duration diff = now - prev;
    48                                 prev = now;
     49                                Duration diff = now - globals.prev;
     50                                globals.prev = now;
    4951                        #endif
    50                         int next = __atomic_add_fetch( &counter, 1, __ATOMIC_SEQ_CST );
     52                        int next = __atomic_add_fetch( &globals.counter, 1, __ATOMIC_SEQ_CST );
    5153                        __cfaabi_check_preemption();
    5254                        if( (next % 100) == 0 ) {
     
    5456                                        unsigned idx = next / 100;
    5557                                        if (idx >= 6) abort | "Idx from next is invalid: " | idx | "vs" | next;
    56                                         preempt_durations[idx] = diff;
     58                                        globals.durations[idx] = diff;
    5759                                        if(diff > 12`s) serr | "Duration suspiciously large:" | diff;
    5860                                #endif
     
    7173int main(int argc, char* argv[]) {
    7274        processor p;
     75        globals.counter = 0;
     76        globals.durations[0] = 0;
     77        globals.durations[1] = 0;
     78        globals.durations[2] = 0;
     79        globals.durations[3] = 0;
     80        globals.durations[4] = 0;
     81        globals.durations[5] = 0;
    7382        {
    74                 prev = timeHiRes();
     83                globals.prev = timeHiRes();
    7584                worker_t w0 = 0;
    7685                worker_t w1 = 1;
Note: See TracChangeset for help on using the changeset viewer.