Quoting sys/dev/vnd.c rev 1.62:
1121 /*
1122 * Wait interruptibly for an exclusive lock.
1123 *
1124 * XXX
1125 * Several drivers do this; it should be abstracted and made MP-safe.
1126 */
1127 int
1128 vndlock(sc)
1129 struct vnd_softc *sc;
1130 {
1131 int error;
1132
1133 while ((sc->sc_flags & VNF_LOCKED) != 0) {
1134 sc->sc_flags |= VNF_WANTED;
1135 if ((error = tsleep(sc, PRIBIO | PCATCH, "vndlck", 0))
!= 0)
1136 return (error);
1137 }
1138 sc->sc_flags |= VNF_LOCKED;
1139 return (0);
1140 }
Is it possible for a process to have the cpu taken away from it
between lines 1137 and 1138?
If so, is the comment "Several drivers do this" serious?