Subject: Re: lock/unlock asymmetry
To: Hauke Fath <hauke@Espresso.Rhein-Neckar.DE>
From: Adam Hamsik <haaaad@gmail.com>
List: tech-kern
Date: 07/08/2007 02:14:22
On Jul 8, 2007, at 1:32 AM, Hauke Fath wrote:

> Hi,
>
> maybe it's the late hour, and I don't understand locks anyway, but...
>
> Looking at the interrupt routines in sys/dev/ic/z8530sc.c, it seems to
> me that the code unlocks channel A twice, and never unlocks
> channel B:
>
>
> [snip]
>
>
> -- anything I missed? That code has been around for a while, after
> all...
>
>         hauke
>
> -- =20
> Hauke Fath				Telefon 06155/667161
> Friedrich-Ebert-Stra=DFe 70
> 64347 Griesheim
> Germany

Hi

that code is here. I'm not guru ut I think that it's good. I will try =20=

to say how I understand it.

/* First look at channel A. */
     295 	cs =3D zsc->zsc_cs[0];
		I think that zsc_cs[0]-> channel A
				   [1]-> channel B
     296
     297 	/* Lock both channels */
		now we lock A && B together.
     298 	simple_lock(&cs->cs_lock);
     299 	simple_lock(&zsc->zsc_cs[1]->cs_lock);
     [Channel A]
     320
     321 	/* Done with channel A */
     322 	simple_unlock(&cs->cs_lock);
     323 	cs-> channel A is unlocked.
     324 	/* Now look at channel B. */
     325 	cs =3D zsc->zsc_cs[1];
		!!!Here cs become Channel B not A  so when we unlock it
		B is unlocked=09
     [Channel B]
     335
     336 	simple_unlock(&cs->cs_lock);

IMHO this code is correct. But I repeat I'm not a guru :).

Regards
-----------------------------------------
Adam Hamsik
jabber: haad@jabber.org
icq: 249727910

Proud NetBSD user.

We program to have fun.
Even when we program for money, we want to have fun as well.
~ Yukihiro Matsumoto