Skip to content

Conversation

cfriedt
Copy link
Member

@cfriedt cfriedt commented Oct 10, 2025

Add support for the times() function, which can be used to get the number of ticks spent in "system" and "user" mode, and which returns the "real time" that has expired, since an arbitrary point in the past.

The following invariant should always hold:

rtime <= stime + utime

The times() function measures time for the calling process and all of it's child processes. In Zephyr, we don't support separate processes (yet), so the time spent in child processes is zero.

Additionally, in Zephyr we do not differentiate between "system" time (i.e. time spent executing kernel code) and "user" time (time spent executing application code). We only have information on "total time" (time spent executing code) and "execution time" (time spent executing code plus idle time).

For now, only report utime, since it is not clear how to obtain other values.

Closes #51978

@cfriedt cfriedt requested review from sylvioalves and ycsin October 10, 2025 13:37
@cfriedt cfriedt force-pushed the add-rough-times-support branch from 2231380 to 911a06e Compare October 10, 2025 13:39
Add support for the `times()` function, which can be used to get the
number of ticks spent in "system" and "user" mode, and which returns
the "real time" that has expired, since an arbitrary point in the past.

The following invariant should always hold:

rtime <= stime + utime

The `times()` function measures time for the calling process and all
of it's child processes. In Zephyr, we don't support separate processes
(yet), so the time spent in child processes is zero.

Additionally, in Zephyr we do not differentiate between "system" time
(i.e. time spent executing kernel code) and "user" time (time spent
executing application code). We only have information on "total time"
(time spent executing code) and "execution time" (time spent executing
code plus idle time).

For now, only report utime, since it is not clear how to obtain other
values.

Signed-off-by: Chris Friedt <[email protected]>
Add a testsuite for the POSIX_MULTI_PROCESS Option Group.

Signed-off-by: Chris Friedt <[email protected]>
@cfriedt cfriedt force-pushed the add-rough-times-support branch from 911a06e to 9cfe84e Compare October 10, 2025 14:11
Copy link

@cfriedt cfriedt marked this pull request as ready for review October 10, 2025 15:44
@zephyrbot zephyrbot added area: POSIX POSIX API Library area: Tests Issues related to a particular existing or missing test labels Oct 10, 2025
@zephyrbot zephyrbot requested a review from nashif October 10, 2025 15:46
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

area: POSIX POSIX API Library area: Tests Issues related to a particular existing or missing test

Projects

None yet

Development

Successfully merging this pull request may close these issues.

Add POSIX times() support

2 participants