On Sun, Sep 10, 2006 at 05:08:49AM +0000, Paul Stoeber wrote:
> 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?

Yes, by an unmasked interrupt, not by another process.

> If so, is the comment "Several drivers do this" serious?

Not really. The comment assumes processes can simultaneously be executed
in kernel mode on different processors. This is not the case in OpenBSD
(for most parts of the code).

-p.

Reply via email to