Ignore:
Timestamp:
Aug 14, 2017, 11:39:03 AM (4 years ago)
Author:
alain
Message:

Change Time unit from cycle to TICK (in millisecond).
Fix several bugs in VFS.

File:
1 edited

Legend:

Unmodified
Added
Removed
  • trunk/kernel/kern/core.c

    r337 r367  
    4747        core->time_stamp        = 0;
    4848        core->ticks_nr          = 0;
    49         core->ticks_period      = CONFIG_SCHED_TICK_PERIOD;
    5049        core->usage             = 0;
    5150        core->spurious_irqs     = 0;
     
    7271                    uint32_t * tm_us )
    7372{
    74         uint64_t cycles = hal_get_cycles();
    75 
    76         *tm_s  = (cycles / CONFIG_CYCLES_PER_MS);
    77         *tm_us = (cycles % CONFIG_CYCLES_PER_MS) / (CONFIG_CYCLES_PER_MS / 1000000);
     73        *tm_s  = (core->ticks_nr*CONFIG_SCHED_TICK_PERIOD)/1000;
     74        *tm_us = (core->ticks_nr*CONFIG_SCHED_TICK_PERIOD*1000)%1000000;
    7875}
    7976
     77/* deprecated 14/08/2017 [AG]
    8078//////////////////////////////////////
    8179void core_time_update( core_t * core )
     
    9997        hal_fence();
    10098}
     99*/
    101100
    102101////////////////////////////////
     
    105104        uint32_t ticks;
    106105
    107         // update cycles and ticks counter
    108         core_time_update( core );
    109 
    110         // get current ticks number
    111         ticks = core->ticks_nr;
     106        // update ticks counter
     107        ticks = core->ticks_nr++;
    112108
    113109        // handle pending alarms TODO ??? [AG]
    114110        // alarm_clock( &core->alarm_mgr , ticks );
    115111
    116         // handle scheduler TODO  improve the scheduling condition ... AG
    117         if( (ticks % 10) == 0 ) sched_yield( NULL );
    118 
    119 /*
    120     // compute elapsed time, taking into account 32 bits register wrap
    121     uint32_t elapsed;
    122     uint32_t time_now   = hal_get_cycles();
    123     uint32_t time_last  = this->time_last_check;
    124     if( time_now < time_last ) elapsed = (0xFFFFFFFF - time_last) + time_now;
    125         else                       elapsed = time_now - time_last;
    126 
    127     // update thread time
    128     this->time_last_check = time_now;
    129 
    130         // check elapsed time
    131         if( elapsed < CONFIG_CORE_CHECK_EVERY ) return false;
    132     else                                    return true;
    133 */
     112        // handle scheduler
     113        if( (ticks % CONFIG_SCHED_TICKS_PER_QUANTUM) == 0 ) sched_yield( NULL );
    134114
    135115        // update DQDT TODO  This update should depend on the cluster identifier,
    136116        // to avoid simultaneous updates from various clusters ... AG
    137         if( ((ticks % CONFIG_DQDT_PERIOD) == 0) && (core->lid == 0) ) dqdt_global_update();
     117        if( ((ticks % CONFIG_DQDT_TICKS_PER_QUANTUM) == 0) && (core->lid == 0) )
     118        dqdt_global_update();
    138119}
    139120
     
    171152void core_reset_stats( core_t * core )
    172153{
    173         core_time_update(core);
    174 
    175154        core->ticks_nr              = 0;
    176155        core->usage                 = 0;
Note: See TracChangeset for help on using the changeset viewer.