diff options
author | hselasky <hselasky@FreeBSD.org> | 2013-08-30 10:39:56 +0000 |
---|---|---|
committer | hselasky <hselasky@FreeBSD.org> | 2013-08-30 10:39:56 +0000 |
commit | 5a68ee8757ca1727e386a511decd12b06cc46466 (patch) | |
tree | ee24966923ad17c876bd1aa4f48f973dd0b74065 /sys/kern | |
parent | 79ac01d192518923ff35984ca6cf99063106d933 (diff) | |
download | FreeBSD-src-5a68ee8757ca1727e386a511decd12b06cc46466.zip FreeBSD-src-5a68ee8757ca1727e386a511decd12b06cc46466.tar.gz |
Simplify pause_sbt() logic. Don't call DELAY() if remainder is less
than or equal to zero.
Diffstat (limited to 'sys/kern')
-rw-r--r-- | sys/kern/kern_synch.c | 14 |
1 files changed, 7 insertions, 7 deletions
diff --git a/sys/kern/kern_synch.c b/sys/kern/kern_synch.c index 0996f4e..b0e1908 100644 --- a/sys/kern/kern_synch.c +++ b/sys/kern/kern_synch.c @@ -356,10 +356,7 @@ msleep_spin_sbt(void *ident, struct mtx *mtx, const char *wmesg, int pause_sbt(const char *wmesg, sbintime_t sbt, sbintime_t pr, int flags) { - int sbt_sec; - - sbt_sec = sbintime_getsec(sbt); - KASSERT(sbt_sec >= 0, ("pause: timo must be >= 0")); + KASSERT(sbt >= 0, ("pause: timeout must be >= 0")); /* silently convert invalid timeouts */ if (sbt == 0) @@ -370,11 +367,14 @@ pause_sbt(const char *wmesg, sbintime_t sbt, sbintime_t pr, int flags) * We delay one second at a time to avoid overflowing the * system specific DELAY() function(s): */ - while (sbt_sec > 0) { + while (sbt >= SBT_1S) { DELAY(1000000); - sbt_sec--; + sbt -= SBT_1S; } - DELAY((sbt & 0xffffffff) / SBT_1US); + /* Do the delay remainder, if any */ + sbt = (sbt + SBT_1US - 1) / SBT_1US; + if (sbt > 0) + DELAY(sbt); return (0); } return (_sleep(&pause_wchan[curcpu], NULL, 0, wmesg, sbt, pr, flags)); |