tech-kern archive

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index][Old Index]

Re: Modules loading modules?



On Sun, Aug 01, 2010 at 06:05:20PM -0700, Paul Goyette wrote:
> On Mon, 2 Aug 2010, Quentin Garnier wrote:
> 
> >>+int
> >>+rmutex_tryenter(rmutex_t *rmtx)
> >>+{
> >>+   int rv = 1;
> >>+
> >>+   if (mutex_owned(&rmtx->rmtx_mtx)) {
> >>+           rmtx->rmtx_recurse++;
> >>+           KASSERT(rmtx->rmtx_recurse != 0);
> >>+   } else if ((rv = mutex_tryenter(&rmtx->rmtx_mtx)) != 0) {
> >>+           rmtx->rmtx_recurse++;
> >>+           KASSERT(rmtx->rmtx_recurse != 0);
> >>+   }
> >>+   return rv;
> >>+}
> >
> >I am probably not getting the idea, but I fail to see how this qualifies
> >as a mutex.  My reading of this piece of code is that rmutex_enter() is
> >always going to succeed immediately.
> 
> According to the mutex(9) man page:
> 
>     mutex_owned(mtx)
> 
>        For adaptive mutexes, return non-zero if the current LWP holds
>        the mutex. ...

Ah, that was what I was missing.  Thanks.

-- 
Quentin Garnier - cube%cubidou.net@localhost - cube%NetBSD.org@localhost
"See the look on my face from staying too long in one place
[...] every time the morning breaks I know I'm closer to falling"
KT Tunstall, Saving My Face, Drastic Fantastic, 2007.

Attachment: pgp8vcZHZwxs1.pgp
Description: PGP signature



Home | Main Index | Thread Index | Old Index