If you are using an rtos similar functions might be provided and you can use those.
How to implement wall clock time and user time c.
The gettimeofday function returns the wall clock time elapsed since the epoch and store it in the timevalstructure expressed as seconds and microseconds.
If second is not a null pointer the returned value is also stored in the object pointed to by second.
The timer makes it easy to implement data and time functions.
Note that ansi c allows for time t to be a float value but this choice seems never to have been made in a real operating system it is rumored that early versions of beos used float time but the experiment was quickly abandoned and is excluded in later posix revisions.
This function returns the time since 00 00 00 utc january 1 1970 unix timestamp in seconds.
To convert the value to seconds it needs to be divided by a macro clocks per sec.
Include time h clock t start end.
The below example is for an arm cortex m device which has a systick timer.
Convert time t to tm as utc time function localtime convert time t to tm as local time function strftime format time as string function macro constants clocks per sec clock ticks per second macro null null pointer macro types clock t clock type type size t unsigned integral type type time t time type type struct tm time.
It depends on how the operating system allocates the resources for the process.
It is defined in sys time h header file and takes two arguments the first arugment is reference to the timevalstructure and the second argument is a null pointer.
The current time t value is returned by the time 3 function.
Time t time time t second.
If the processor is shared by other processes the clock time may advance slower than the wall clock.
C library quick guide.
To calculate time taken by a process we can use clock function which is available time h we can call the clock function at the beginning and end of the code for which we measure time subtract the values and then divide by clocks per sec the number of clock ticks per second to get processor time like following.
Without the debugger the application must implement the low level implementation of the date and time library.