Allow pause_sbt() to catch signals during sleep by passing C_CATCH flag.

Define pause_sig() function macro helper similarly to other kernel functions
which catch signals. Update outdated function description.

Discussed with:	kib@
MFC after:	1 week
Sponsored by:	Mellanox Technologies
This commit is contained in:
Hans Petter Selasky 2018-03-03 18:36:38 +00:00
parent 3177f7cda1
commit 2077229b56
Notes: svn2git 2020-12-20 02:59:44 +00:00
svn path=/head/; revision=330349
3 changed files with 11 additions and 7 deletions

View File

@ -297,16 +297,16 @@ msleep_spin_sbt(void *ident, struct mtx *mtx, const char *wmesg,
}
/*
* pause() delays the calling thread by the given number of system ticks.
* During cold bootup, pause() uses the DELAY() function instead of
* the tsleep() function to do the waiting. The "timo" argument must be
* greater than or equal to zero. A "timo" value of zero is equivalent
* to a "timo" value of one.
* pause_sbt() delays the calling thread by the given signed binary
* time. During cold bootup, pause_sbt() uses the DELAY() function
* instead of the _sleep() function to do the waiting. The "sbt"
* argument must be greater than or equal to zero. A "sbt" value of
* zero is equivalent to a "sbt" value of one tick.
*/
int
pause_sbt(const char *wmesg, sbintime_t sbt, sbintime_t pr, int flags)
{
KASSERT(sbt >= 0, ("pause: timeout must be >= 0"));
KASSERT(sbt >= 0, ("pause_sbt: timeout must be >= 0"));
/* silently convert invalid timeouts */
if (sbt == 0)
@ -328,7 +328,8 @@ pause_sbt(const char *wmesg, sbintime_t sbt, sbintime_t pr, int flags)
DELAY(sbt);
return (EWOULDBLOCK);
}
return (_sleep(&pause_wchan[curcpu], NULL, 0, wmesg, sbt, pr, flags));
return (_sleep(&pause_wchan[curcpu], NULL,
(flags & C_CATCH) ? PCATCH : 0, wmesg, sbt, pr, flags));
}
/*

View File

@ -60,6 +60,7 @@
#define C_HARDCLOCK 0x0100 /* align to hardclock() calls */
#define C_ABSOLUTE 0x0200 /* event time is absolute. */
#define C_PRECALC 0x0400 /* event time is pre-calculated. */
#define C_CATCH 0x0800 /* catch signals, used by pause_sbt(9) */
struct callout_handle {
struct callout *callout;

View File

@ -411,6 +411,8 @@ int pause_sbt(const char *wmesg, sbintime_t sbt, sbintime_t pr,
int flags);
#define pause(wmesg, timo) \
pause_sbt((wmesg), tick_sbt * (timo), 0, C_HARDCLOCK)
#define pause_sig(wmesg, timo) \
pause_sbt((wmesg), tick_sbt * (timo), 0, C_HARDCLOCK | C_CATCH)
#define tsleep(chan, pri, wmesg, timo) \
_sleep((chan), NULL, (pri), (wmesg), tick_sbt * (timo), \
0, C_HARDCLOCK)