Run callouts during infinite waiting inside cv_wait

During cv_wait we may be waiting for an event triggered by callout.
Run callbacks here to avoid code blocking.

Reviewed by:   hselasky
Submitted by:  Wojciech Macek <wma@semihalf.com>
Obtained from: Semihalf
Sponsored by:  Juniper Networks Inc.
Differential Revision: https://reviews.freebsd.org/D4144
This commit is contained in:
Zbigniew Bodek 2015-11-27 18:19:11 +00:00
parent bbcfaa4eb8
commit 5bb01ba335
Notes: svn2git 2020-12-20 02:59:44 +00:00
svn path=/head/; revision=291403

View File

@ -138,6 +138,7 @@ cv_timedwait(struct cv *cv, struct mtx *mtx, int timo)
{
int start = ticks;
int delta;
int time = 0;
if (cv->sleeping)
return (EWOULDBLOCK); /* not allowed */
@ -154,6 +155,14 @@ cv_timedwait(struct cv *cv, struct mtx *mtx, int timo)
usb_idle();
if (++time >= (1000000 / hz)) {
time = 0;
callout_process(1);
}
/* Sleep for 1 us */
delay(1);
mtx_lock(mtx);
}