summaryrefslogtreecommitdiffstats
path: root/share/man/man9/tsleep.9 (follow)
Commit message (Collapse)AuthorAgeFilesLines
* tsleep_nsec(9): add MAXTSLP macro, the maximum sleep durationcheloha2020-03-201-2/+3
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | This macro will be useful for truncating durations below INFSLP (UINT64_MAX) when converting from a timespec or timeval to a count of nanoseconds before calling tsleep_nsec(9), msleep_nsec(9), or rwsleep_nsec(9). A relative timespec can hold many more nanoseconds than a uint64_t can. TIMESPEC_TO_NSEC() and TIMEVAL_TO_NSEC() check for overflow, returning UINT64_MAX if the conversion would overflow a uint64_t. Thus, MAXTSLP will make it easy to avoid inadvertently passing INFSLP to tsleep_nsec(9) et al. when the caller intended to set a timeout. The code in such a case might look something like this: uint64_t nsecs = MIN(TIMESPEC_TO_NSEC(&ts), MAXTSLP); The macro may also be useful for rejecting intervals that are "too large", e.g. for sockets with timeouts, if the timeout duration is to be stored as a uint64_t in an object in the kernel. The code in such a case might look something like this: case SIOCTIMEOUT: { struct timeval *tv = (struct timeval *)data; uint64_t nsecs; if (tv->tv_sec < 0 || !timerisvalid(tv)) return EINVAL; nsecs = TIMEVAL_TO_NSEC(tv); if (nsecs > MAXTSLP) return EOVERFLOW; obj.timeout = nsecs; break; } Idea suggested by visa@. ok visa@
* *sleep_nsec(9): sleep *at least* the given number of nanosecondscheloha2020-01-121-3/+3
| | | | | | | | | | | | | | | | | | | | | 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@
* Add tsleep_nsec(9), msleep_nsec(9), and rwsleep_nsec(9).cheloha2019-07-031-7/+74
| | | | | | | | | | | | | | | | | | | | | | | | Equivalent to their unsuffixed counterparts except that (a) they take a timeout in terms of nanoseconds, and (b) INFSLP, aka UINT64_MAX (not zero) indicates that a timeout should not be set. For now, zero nanoseconds is not a strictly valid invocation: we log a warning on DIAGNOSTIC kernels if we see such a call. We still sleep until the next tick in such a case, however. In the future this could become some sort of poll... TBD. To facilitate conversions to these interfaces: add inline conversion functions to sys/time.h for turning your timeout into nanoseconds. Also do a few easy conversions for warmup and to demonstrate how further conversions should be done. Lots of input from mpi@ and ratchov@. Additional input from tedu@, deraadt@, mortimer@, millert@, and claudio@. Partly inspired by FreeBSD r247787. positive feedback from deraadt@, ok mpi@
* rwsleep: generalize to support both read- and write-locks.cheloha2018-05-281-6/+6
| | | | | | | Wanted for tentative clock_nanosleep(2) diff, but maybe useful elsewhere in the future. ok mpi@
* Introduce rwsleep(9), an equivalent to msleep(9) but for code protectedmpi2016-09-131-6/+27
| | | | | | by a write lock. ok guenther@, vgross@
* Remove useless quoting from .Fo and .Fn function names, to preventschwarze2015-09-141-7/+7
| | | | | | development of a cargo cult in case people look at existing files for examples. This achieves a consistent .Fo and .Fn quoting style across the whole tree.
* - add wakep_{n,one} to NAME and more fully into DESCRIPTIONjmc2014-01-221-7/+12
| | | | - zap eol whitespace
* wakeup_n and wakeup_one blurbstedu2014-01-221-2/+16
|
* Replace old-fashioned .Fd by new-fangled .In for #include lines.schwarze2013-06-041-4/+4
| | | | | Diff from Jan Klemkow <j dot klemkow at wemelug dot de> on tech@. No objection from jmc@ against this type of change.
* these functions are in systm.h now, reminded by kettenistedu2010-04-081-3/+3
|
* First pass at removing clauses 3 and 4 from NetBSD licenses.ray2008-06-261-9/+2
| | | | | | | | | Not sure what's more surprising: how long it took for NetBSD to catch up to the rest of the BSDs (including UCB), or the amount of code that NetBSD has claimed for itself without attributing to the actual authors. OK deraadt@
* Correct a typo:oga2008-04-171-3/+3
| | | | | | tsleep -> msleep from Paul de Weerd, Thanks!
* - better integrate msleep() into this pagejmc2007-11-291-20/+17
| | | | | | - art says bpendsleep has been removed, so kill it ok art
* <oga> art write me a manpageart2007-11-281-2/+19
| | | | | | | | <art> What? Write it yourself. <oga> sudo art write me a manpage. <art> ok Document msleep(9).
* sleep(9) was removed aeons ago according to miod, so remove referencesmk2007-09-141-0/+172
to it. Because man pages are named after functions (at least they should be) and sleep(9) doesn't exist anymore, sleep.9 is renamed to tsleep.9. Input and reminders from jmc and ratchov.