Hi, I noticed clock_gettime(2) describes a CLOCK_VIRTUAL clock that measures how long a process has run in user-space. However, it is not implemented in sys/kern/kern_time.c where it fails with EINVAL in the default switch case.
It does seem to be implemented in FreeBSD and NetBSD along with a CLOCK_PROF counterpart. It is not part of POSIX, but a quick online search suggests it might have been part of ancient POSIX revisions (that I don't have access to). I see these options: 1) Remove CLOCK_VIRTUAL fully as it doesn't work and is non-standard. This might break some ports but that code wasn't working in the first place. 2) Don't mention it at all in clock_gettime(2) and keep it for compatibility purposes. 3) Document it is unimplemented in the BUGS section. 4) Implement it. The kernel already has the information to implement getrusage(2) and the CLOCK_PROCESS_CPUTIME_ID case is similar. If it remains documented, it should also be marked as an extension under STANDARDS. Additionally, perhaps further clocks should be added to get the individual user-time and system-time components of CLOCK_PROCESS_CPUTIME_ID and CLOCK_THREAD_CPUTIME_ID? These can be determined in the process case with getrusage(2), but I know of no way in the thread case. Jonas