OpenBSD cvs log

created 2020-01-20T04:49:17Z
begin 2020-01-12T00:00:00Z
end 2020-01-12T00:01:12Z
path src/sys
commits 1

date 2020-01-12T00:01:12Z
author cheloha
files src/sys/kern/kern_synch.c log diff annotate
message *sleep_nsec(9): sleep *at least* the given number of nanoseconds

The *sleep(9) interfaces are challenging to use when one needs to sleep
for a given minimum duration: the programmer needs to account for both
the current tick and any integer division when converting an interval
to a count of ticks. This sort of input conversion is complicated and
ugly at best and error-prone at worst.

This patch consolidates this conversion logic into the *sleep_nsec(9)
functions themselves. This will allow us to use the functions at the
syscall layer and elsewhere in the kernel where guaranteeing a minimum
sleep duration is of vital importance.

With input from bluhm@, guenther@, ratchov@, tedu@, and kettenis@.

Requested by mpi@ and kettenis@.

Conversion algorithm from mpi@.

ok mpi@, kettenis@, deraadt@