On Sun, Oct 25, 2009 at 05:31:53PM +0100, Hans Petter Selasky wrote: > On Sunday 25 October 2009 15:37:43 Mindaugas Rasiukevicius wrote: > > Hans Petter Selasky <hselasky%c2i.net@localhost> wrote: > > > 39 static __inline int > > > 40 __SIMPLELOCK_LOCKED_P(__cpu_simple_lock_t *__ptr) > > > 41 { > > > 42 return *__ptr == __SIMPLELOCK_LOCKED; > > > 43 } > > > > > > 72 #define __SIMPLELOCK_LOCKED 1 > > > 73 #define __SIMPLELOCK_UNLOCKED 0 > > > > > > mutex_owned() == 1 for spin locks ??? > > > > Yes, it is a comparison. Which is correct for the purpose. > > And what is the purpose of that function? Internal only? > > The comparison is right when done by the locking CPU, but if there are two > CPU's and the non-locking CPU checks this flag at the same time, it gets a 1 > aswell, which is wrong. I think you should read the NetBSD man page of that function. From what you say it appears to me you might have the semantics of FreeBSD's mtx_owned(9) in mind, although it's not clear from their man page what is supposed to happen with spin locks. -- 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:
pgp8_p_bz1gf4.pgp
Description: PGP signature