OpenBSD CVS

CVS log for src/share/man/man9/tsleep.9


[BACK] Up to [local] / src / share / man / man9

Request diff between arbitrary revisions


Default branch: MAIN


Revision 1.16 / (download) - annotate - [select for diffs], Thu Mar 31 17:27:23 2022 UTC (2 years, 2 months ago) by naddy
Branch: MAIN
CVS Tags: OPENBSD_7_5_BASE, OPENBSD_7_5, OPENBSD_7_4_BASE, OPENBSD_7_4, OPENBSD_7_3_BASE, OPENBSD_7_3, OPENBSD_7_2_BASE, OPENBSD_7_2, OPENBSD_7_1_BASE, OPENBSD_7_1, HEAD
Changes since 1.15: +3 -3 lines
Diff to previous 1.15 (colored)

man pages: add missing commas between subordinate and main clauses

jmc@ dislikes a comma before "then" in a conditional, so leave those
untouched.

ok jmc@

Revision 1.15 / (download) - annotate - [select for diffs], Fri Mar 20 03:37:09 2020 UTC (4 years, 2 months ago) by cheloha
Branch: MAIN
CVS Tags: OPENBSD_7_0_BASE, OPENBSD_7_0, OPENBSD_6_9_BASE, OPENBSD_6_9, OPENBSD_6_8_BASE, OPENBSD_6_8, OPENBSD_6_7_BASE, OPENBSD_6_7
Changes since 1.14: +3 -2 lines
Diff to previous 1.14 (colored)

tsleep_nsec(9): add MAXTSLP macro, the maximum sleep duration

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@

Revision 1.14 / (download) - annotate - [select for diffs], Sun Jan 12 00:01:12 2020 UTC (4 years, 4 months ago) by cheloha
Branch: MAIN
Changes since 1.13: +3 -3 lines
Diff to previous 1.13 (colored)

*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@

Revision 1.13 / (download) - annotate - [select for diffs], Wed Jul 3 22:39:33 2019 UTC (4 years, 11 months ago) by cheloha
Branch: MAIN
CVS Tags: OPENBSD_6_6_BASE, OPENBSD_6_6
Changes since 1.12: +74 -7 lines
Diff to previous 1.12 (colored)

Add tsleep_nsec(9), msleep_nsec(9), and rwsleep_nsec(9).

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@

Revision 1.12 / (download) - annotate - [select for diffs], Mon May 28 18:51:27 2018 UTC (6 years ago) by cheloha
Branch: MAIN
CVS Tags: OPENBSD_6_5_BASE, OPENBSD_6_5, OPENBSD_6_4_BASE, OPENBSD_6_4
Changes since 1.11: +6 -6 lines
Diff to previous 1.11 (colored)

rwsleep: generalize to support both read- and write-locks.

Wanted for tentative clock_nanosleep(2) diff, but maybe useful
elsewhere in the future.

ok mpi@

Revision 1.11 / (download) - annotate - [select for diffs], Tue Sep 13 08:32:44 2016 UTC (7 years, 8 months ago) by mpi
Branch: MAIN
CVS Tags: OPENBSD_6_3_BASE, OPENBSD_6_3, OPENBSD_6_2_BASE, OPENBSD_6_2, OPENBSD_6_1_BASE, OPENBSD_6_1
Changes since 1.10: +27 -6 lines
Diff to previous 1.10 (colored)

Introduce rwsleep(9), an equivalent to msleep(9) but for code protected
by a write lock.

ok guenther@, vgross@

Revision 1.10 / (download) - annotate - [select for diffs], Mon Sep 14 15:14:55 2015 UTC (8 years, 8 months ago) by schwarze
Branch: MAIN
CVS Tags: OPENBSD_6_0_BASE, OPENBSD_6_0, OPENBSD_5_9_BASE, OPENBSD_5_9
Changes since 1.9: +6 -6 lines
Diff to previous 1.9 (colored)

Remove useless quoting from .Fo and .Fn function names, to prevent
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.

Revision 1.9 / (download) - annotate - [select for diffs], Wed Jan 22 07:32:47 2014 UTC (10 years, 4 months ago) by jmc
Branch: MAIN
CVS Tags: OPENBSD_5_8_BASE, OPENBSD_5_8, OPENBSD_5_7_BASE, OPENBSD_5_7, OPENBSD_5_6_BASE, OPENBSD_5_6, OPENBSD_5_5_BASE, OPENBSD_5_5
Changes since 1.8: +13 -8 lines
Diff to previous 1.8 (colored)

- add wakep_{n,one} to NAME and more fully into DESCRIPTION
- zap eol whitespace

Revision 1.8 / (download) - annotate - [select for diffs], Wed Jan 22 00:09:02 2014 UTC (10 years, 4 months ago) by tedu
Branch: MAIN
Changes since 1.7: +16 -2 lines
Diff to previous 1.7 (colored)

wakeup_n and wakeup_one blurbs

Revision 1.7 / (download) - annotate - [select for diffs], Tue Jun 4 19:27:14 2013 UTC (11 years ago) by schwarze
Branch: MAIN
CVS Tags: OPENBSD_5_4_BASE, OPENBSD_5_4
Changes since 1.6: +4 -4 lines
Diff to previous 1.6 (colored)

Replace old-fashioned .Fd by new-fangled .In for #include lines.
Diff from Jan Klemkow <j dot klemkow at wemelug dot de> on tech@.
No objection from jmc@ against this type of change.

Revision 1.6 / (download) - annotate - [select for diffs], Thu Apr 8 00:16:28 2010 UTC (14 years, 2 months ago) by tedu
Branch: MAIN
CVS Tags: OPENBSD_5_3_BASE, OPENBSD_5_3, OPENBSD_5_2_BASE, OPENBSD_5_2, OPENBSD_5_1_BASE, OPENBSD_5_1, OPENBSD_5_0_BASE, OPENBSD_5_0, OPENBSD_4_9_BASE, OPENBSD_4_9, OPENBSD_4_8_BASE, OPENBSD_4_8
Changes since 1.5: +3 -3 lines
Diff to previous 1.5 (colored)

these functions are in systm.h now, reminded by kettenis

Revision 1.5 / (download) - annotate - [select for diffs], Thu Jun 26 05:42:08 2008 UTC (15 years, 11 months ago) by ray
Branch: MAIN
CVS Tags: OPENBSD_4_7_BASE, OPENBSD_4_7, OPENBSD_4_6_BASE, OPENBSD_4_6, OPENBSD_4_5_BASE, OPENBSD_4_5, OPENBSD_4_4_BASE, OPENBSD_4_4
Changes since 1.4: +2 -9 lines
Diff to previous 1.4 (colored)

First pass at removing clauses 3 and 4 from NetBSD licenses.

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@

Revision 1.4 / (download) - annotate - [select for diffs], Thu Apr 17 00:11:02 2008 UTC (16 years, 1 month ago) by oga
Branch: MAIN
Changes since 1.3: +3 -3 lines
Diff to previous 1.3 (colored)

Correct a typo:
tsleep -> msleep

from Paul de Weerd, Thanks!

Revision 1.3 / (download) - annotate - [select for diffs], Thu Nov 29 11:33:05 2007 UTC (16 years, 6 months ago) by jmc
Branch: MAIN
CVS Tags: OPENBSD_4_3_BASE, OPENBSD_4_3
Changes since 1.2: +17 -20 lines
Diff to previous 1.2 (colored)

- better integrate msleep() into this page
- art says bpendsleep has been removed, so kill it

ok art

Revision 1.2 / (download) - annotate - [select for diffs], Wed Nov 28 23:24:07 2007 UTC (16 years, 6 months ago) by art
Branch: MAIN
Changes since 1.1: +19 -2 lines
Diff to previous 1.1 (colored)

<oga> art write me a manpage
<art> What? Write it yourself.
<oga> sudo art write me a manpage.
<art> ok

Document msleep(9).

Revision 1.1 / (download) - annotate - [select for diffs], Fri Sep 14 16:16:08 2007 UTC (16 years, 8 months ago) by mk
Branch: MAIN

sleep(9) was removed aeons ago according to miod, so remove references
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.

This form allows you to request diff's between any two revisions of a file. You may select a symbolic revision name using the selection box or you may type in a numeric name using the type-in text box.