Skip site navigation (1)Skip section navigation (2)
Date:      Mon, 27 Dec 2004 15:38:11 -0500
From:      John Baldwin <jhb@FreeBSD.org>
To:        freebsd-hackers@FreeBSD.org
Subject:   Re: Kernel crash w/o reason
Message-ID:  <200412271538.11938.jhb@FreeBSD.org>
In-Reply-To: <Pine.LNX.4.61.0412241311530.19395@yvahk01.tjqt.qr>
References:  <Pine.GSO.4.43.0412231700480.8053-100000@sea.ntplx.net> <Pine.LNX.4.61.0412241311530.19395@yvahk01.tjqt.qr>

next in thread | previous in thread | raw e-mail | index | archive | help
On Friday 24 December 2004 07:13 am, Jan Engelhardt wrote:
> >> What should I use instead? A semaphore?
> >
> >You shouldn't have unrelated kernel threads waiting for a user
> >process at all, so this sounds like a design problem, regardless
> >of which mutual exclusion primitive you use.  (Bear in mind that I
> >haven't actually looked into what you're trying to do.)  In any
> >case, you can always use mutexes to implement whatever other
> >synchronization mechanism you need.
>
> I wanted that the device can only be opened once, and holding a mutex while
> it is open seemed like a simple idea. (Since mtx_trylock() will then fail
> -- easy to implement.)

Use a flag in your softc and use a mutex to protect access to the flag.

-- 
John Baldwin <jhb@FreeBSD.org>  <><  http://www.FreeBSD.org/~jhb/
"Power Users Use the Power to Serve"  =  http://www.FreeBSD.org



Want to link to this message? Use this URL: <https://mail-archive.FreeBSD.org/cgi/mid.cgi?200412271538.11938.jhb>