Subject: Re: Kernel threads
To: Ben Harris <bjh21@netbsd.org>
From: Bharani Chadalavada <bharani.chadalavada@nexsi.com>
List: tech-kern
Date: 04/02/2001 11:58:34
Hi Ben

This could actually work. I will try this and also try the soft interrupt option
and see what will happen.

Thank you guys for your suggestions!!

Bharani.

Ben Harris wrote:

> The usual simple way around this would be to disable serial interrupts
> before the call to write_bytes(), but you seem to say that's impossible.
>
> How about something like this:
>
> while (1) {
>         flag = 0;
>         write_bytes();
>         s = splhigh();
>         while (flag == 0)
>                 tsleep(&flag, ...);
>         splx(s);
> }
>
> and in the interrupt routine:
>
> flag = 1;
> wakeup(&flag);
>
> If the interrupt gets in between the write_bytes() and the splhigh(), it'll
> just set the flag, which will cause the sleep not to happen.  Of course, you
> can (and should) replace splhigh() with the right level to disable the
> serial interrupts.
>
> --
> Ben Harris                                                   <bjh21@netbsd.org>
> Portmaster, NetBSD/arm26               <URL:http://www.netbsd.org/Ports/arm26/>