Restore the locking for the sleep/wakeup to avoid waiting an extra 1 sec

if a race was lost.  We're still single-threaded at this point, but just
be safe for the future.
This commit is contained in:
Nate Lawson 2007-04-09 21:10:04 +00:00
parent 1f13edbe4b
commit a363f67a81
Notes: svn2git 2020-12-20 02:59:44 +00:00
svn path=/head/; revision=168552

View File

@ -1378,12 +1378,13 @@ root_mount_done(void)
{
/*
* No mutex is acquired here because int stores are atomic. If a
* thread is polling root_mount_complete, it may get a spurious
* wakeup() but that is fine in the tsleep()/wakeup() model.
* Use a mutex to prevent the wakeup being missed and waiting for
* an extra 1 second sleep.
*/
mtx_lock(&mountlist_mtx);
root_mount_complete = 1;
wakeup(&root_mount_complete);
mtx_unlock(&mountlist_mtx);
}
/*
@ -1393,6 +1394,7 @@ int
root_mounted(void)
{
/* No mutex is acquired here because int stores are atomic. */
return (root_mount_complete);
}
@ -1409,8 +1411,12 @@ root_mount_wait(void)
*/
KASSERT(curthread->td_proc->p_pid != 0,
("root_mount_wait: cannot be called from the swapper thread"));
while (!root_mount_complete)
tsleep(&root_mount_complete, PZERO, "rootwait", hz);
mtx_lock(&mountlist_mtx);
while (!root_mount_complete) {
msleep(&root_mount_complete, &mountlist_mtx, PZERO, "rootwait",
hz);
}
mtx_unlock(&mountlist_mtx);
}
static void