Changeset 0f1fb78


Ignore:
Timestamp:
May 15, 2021, 4:39:51 PM (17 months ago)
Author:
caparsons <caparson@…>
Branches:
arm-eh, enum, forall-pointer-decay, jacob/cs343-translation, master, new-ast-unique-expr, pthread-emulation, qualifiedEnum
Children:
a6a4dbd
Parents:
9449085
Message:

put timeval calculation into alarm_node ctor to alleviate slowdowns due to preemption

File:
1 edited

Legend:

Unmodified
Added
Removed
  • libcfa/src/concurrency/alarm.cfa

    r9449085 r0f1fb78  
    5555        this.period  = period;
    5656        this.thrd = thrd;
     57        this.timeval = __kernel_get_time() + alarm;
    5758        set = false;
    5859        type = User;
     
    6364        this.period  = period;
    6465        this.proc = proc;
     66        this.timeval = __kernel_get_time() + alarm;
    6567        set = false;
    6668        type = Kernel;
    6769}
    6870void ?{}( alarm_node_t & this, Alarm_Callback callback, Duration alarm, Duration period ) with( this ) {
     71        this.callback = callback;
    6972        this.initial = alarm;
    7073        this.period  = period;
    71         this.callback = callback;
     74        this.timeval = __kernel_get_time() + alarm;
    7275        set = false;
    7376        type = Callback;
     
    110113        lock( event_kernel->lock __cfaabi_dbg_ctx2 );
    111114        {
    112                 Time curr = __kernel_get_time();
    113                 this->timeval = curr + this->initial;
    114 
    115115                /* paranoid */ verify( validate( alarms ) );
    116116
     117                Time curr = __kernel_get_time();
    117118                __cfadbg_print_safe( preemption, " KERNEL: alarm inserting %p (%lu -> %lu).\n", this, curr.tn, this->timeval.tn );
    118119                insert( &alarms, this );
    119                 __kernel_set_timer( this->initial );
     120                __kernel_set_timer( this->timeval - curr);
    120121        }
    121122        unlock( event_kernel->lock );
Note: See TracChangeset for help on using the changeset viewer.