FreeRTOS/Demo/RISC-V_RV32_SiFive_HiFive1-RevB_FreedomStudio/freedom-metal/gloss/sys_times.c
/* Timing information for current process. From
   newlib/libc/include/sys/times.h the tms struct fields are as follows:

   - clock_t tms_utime  : user clock ticks
   - clock_t tms_stime  : system clock ticks
   - clock_t tms_cutime : children's user clock ticks
   - clock_t tms_cstime : children's system clock ticks

   Since maven does not currently support processes we set both of the
   children's times to zero. Eventually we might want to separately
   account for user vs system time, but for now we just return the total
   number of cycles since starting the program.  */
Timing information for current process. From
newlib/libc/include/sys/times.h the tms struct fields are as follows.



Since maven does not currently support processes we set both of the
children's times to zero. Eventually we might want to separately
account for user vs system time, but for now we just return the total
number of cycles since starting the program.
Timing information for current process . From newlib / libc / include / sys / times . h the tms struct fields are as follows . Since maven does not currently support processes we set both of the children ' s times to zero . Eventually we might want to separately account for user vs system time but for now we just return the total number of cycles since starting the program .
clock_t _times(struct tms *buf) {
    unsigned long long mcc;
    unsigned long long timebase;
    int hartid = metal_cpu_get_current_hartid();
    metal_timer_get_timebase_frequency(hartid, &timebase);
    metal_timer_get_cyclecount(hartid, &mcc);
    mcc = muldiv(mcc, CLOCKS_PER_SEC, timebase);
    buf->tms_stime = 0;
    buf->tms_cutime = 0;
    buf->tms_cstime = 0;
    return buf->tms_utime = mcc;
}
clock_t _times ( struct tms * buf ) { unsigned long long mcc ; unsigned long long timebase ; int hartid = metal_cpu_get_current_hartid ( ) ; metal_timer_get_timebase_frequency ( hartid , & timebase ) ; metal_timer_get_cyclecount ( hartid , & mcc ) ; mcc = muldiv ( mcc , CLOCKS_PER_SEC , timebase ) ; buf -> tms_stime = 0 ; buf -> tms_cutime = 0 ; buf -> tms_cstime = 0 ; return buf -> tms_utime = mcc ; }
Timing information for current process.
Timing information for current process .
/*
     * Convert from native resolution to published resolution.
     *
     * Truncating this to 64 bits works because a change of 'c' in
     * cyclecount will change the return value by
     * c * CLOCKS_PER_SEC / timebase, so applications will see
     * time marching forward.
     */