Commit Graph

3 Commits

Author SHA1 Message Date
Yuta Saito
67080fa045
times should always return 0 for tms_cutime (#510)
`tms_cutime` is the sum of the user times of child processes *excluding
the current process*. Since WASI doesn't provide a way to spawn a new
process, this value should always be 0.
2024-07-02 22:46:25 -07:00
Dan Gohman
c82d116de0 Add some more comments. 2021-03-23 10:34:46 -07:00
Dan Gohman
b9b64a695a Emulate clock, times, and getrusage using the monotonic clock.
Upcoming WASI snapshots omit the `PROCESS_CPUTIME` clock, since WASI has
no inherent concept of processes, and since implementations which don't
use a process for each instance don't have a way to implement it
efficiently.

However, `clock`, `times`, and `getrusage` are useful functions, so
provide optional emulated version of them, using the `MONOTONIC` clock.
This means these implementations will measure not just the program's
own CPU time, but also time spent suspended while other programs are
running.

Due to this difference in behavior, put these implementations behind
a flag. Users must pass `-D_WASI_EMULATED_PROCESS_CLOCK` and link with
`-lwasi-emulated-process-clocks` to enable them.
2021-03-23 10:34:46 -07:00