Subject: Re: Synchronization with locks in kernel
To: Ian Zagorskih <ianzag@megasignal.com>
From: Jachym Holecek <freza@psi.cz>
List: tech-kern
Date: 06/23/2003 01:35:37
Hello,
> But how does it actually work ? What means "blocking interrupt at some
See below.
> level" ? I'm attaching ISA interrupt handler at IPL_SERIAL level so
> i call splserial() to "block" interrupts of my level and after
> tsleep() returns i unblock them. Ok, seems to work. But "man spl"
> says that:
> ------
> splserial() blocks hard interrupts from serial interfaces (IPL_SERI-
> [...]
> ------
>
> i.e. as i understand, *all* interrupts of this level including RS232
> ports etc are blocked.
Yes.
> ------
> /* save old mask, block serial */
> s = splserial();
>
> /* request interrupt */
> dev_request_interrupt(sc);
> [1]
> print("tralala\n");
> tsleep(sc); [2]
> /* restpre old mask */
> splx(s);
> ------
[1] The interrupt is masked/blocked, you will not be bothered by your
interrupt handler. You may safely manipulate data shared with the
handler etc.
[2] ltsleep() -> mi_switch() -> cpu_switch()
The cpu_switch routine (temporarily?) lowers SPL to zero (calling
spl0() or splx(SPL_NONE)), your handler gets chance to run and
eventually awaken your process (returning from tsleep()).
Well, that's what I found going through kern/kern_synch.c and
Arch/arm/ code... no warranty ;-)
HTH,
-- Jachym Holecek