On Sun, 3 Dec 2017, Stephen Graf wrote: > I am working on sxitwi.c and have a question on the tsleep function. > > Any documentation describes the timo parameter to tsleep as: > > If non-zero, the process will sleep for at most timo/hz seconds. If this > amount of time elapses and no wakeup(ident) has occurred, and no signal > (if PCATCH was set) was posted, tsleep() will return EWOULDBLOCK. > > I would like to know what ?timo/hz? means. Hz is the symbol for cycles, > but what does it mean in this context?
In this context it's referring not to the unit of Hertz but rather to the 'hz' kernel variable, as documented in the hz(9) manpage which is listed in the SEE ALSO section. > If the timo parameter is set to 100, does tsleep sleep for at most 100 > seconds or 100 divided by something? 100 / hz, which on most OpenBSD archs will end up being 1 second. If you know your desired duration, then just do the arithmetic with 'hz' to get the necessary 'timo' value to pass. If you look around the device tree you'll find examples. There are helper functions tvtohz(9) and tstohz (on the same manpage) for converting timeval or timespec values to 'timo' for use with tsleep and friends, but those are more for when you get such a value from userspace. Philip Guenther