CVSROOT:        /cvs
Module name:    src
Changes by:     chel...@cvs.openbsd.org 2020/08/12 09:31:27

Modified files:
        sys/kern       : kern_time.c 

Log message:
getitimer(2): delay TIMESPEC_TO_TIMEVAL(9) conversion until copyout(9)

setitimer(2) works with timespecs in its critical section.  It will be
easier to merge the two critical sections if getitimer(2) also works
with timespecs.

In particular, we currently read the uptime clock *twice* during a
setitimer(2) swap: we call getmicrouptime(9) in sys_getitimer() and
then call getnanouptime(9) in sys_setitimer().  This means that
swapping one timer in for another is not atomic with respect to the
uptime clock.  It also means the two operations are working with
different time structures and resolutions, which is potentially
confusing.

If both critical sections work with timespecs we can combine the two
getnanouptime(9) calls into a single call at the start of the combined
critical section in a future patch, making the swap atomic with
respect to the clock.

So, in preparation, move the TIMESPEC_TO_TIMEVAL conversions in
getitimer(2) after the ITIMER_REAL conversion from absolute to
relative time, just before copyout(9).  The ITIMER_REAL conversion
must then be done with timespec macros and getnanouptime(9), just like
in setitimer(2).

Reply via email to