Nios® V Processor Software Developer Handbook

ID 743810
Date 7/08/2024
Public
Document Table of Contents

16.1.1.69. times()

Prototype

clock_t times (struct tms *buf)

Commonly Called By

C/C++ programs

Device drivers

Thread-safe

Yes.

Available from ISR

Yes.

Include

<sys/times.h>

Description

This times() function is provided for compatibility with newlib. It returns the number of clock ticks since reset. It also fills in the structure pointed to by the input parameter buf with time accounting information. The definition of the tms structure is:

typedef struct 
{
 clock_t tms_utime;
 clock_t tms_stime;
 clock_t tms_cutime;
 clock_t tms_cstime;
};

The structure has the following elements:

  • tms_utime: the processor time charged for the execution of user instructions
  • tms_stime: the processor time charged for execution by the system on behalf of the process
  • tms_cutime: the sum of the values of tms_utime and tms_cutime for all child processes
  • tms_cstime: the sum of the values of tms_stime and tms_cstime for all child processes

    In practice, all elapsed time is accounted as system time. No time is ever attributed as user time. In addition, no time is allocated to child processes, as child processes cannot be spawned by the HAL.

Return

If there is no system clock available, the return value is zero, and errno is set to ENOSYS.