On Tue, May 19, 2009 at 1:33 AM, Ole Loots <o...@monochrom.net> wrote:
> Hello to the list,
>
> I got a question about spinlocks. Here is some pseudo-code:
>
> my_external_int_handler(...)
> {
>   spin_lock(&my_lock);
>   // do things...
>   spin_unlock(&my_lock);
> }
>
> my_ioctl_handler(ioctl_value)
> {
>   switch(ioctl_value)
>   {
>      case xy:
>            spin_lock_irqsave(&my_lock, flags);
>               // do stuff
>            spin_unlock_irqsave(&my_lock, flags);
>      break;
>   }
> }
>
> I just wan't to ensure that the interrupt is finished before I handle the
> IOCTL request, so that I'm not running into a race condition that would a
> affect an ring buffer.
> But what happens when an interrupt signal is triggered at the external
> interrupt pin, does spin_lock_irqsave que the interrupt? Or does it dismiss
> the interrupt?

Your questions is very hardware specific.   For intel x86, it is
specifically documented in the manual that when the CPU has its
interrupt disabled, at most ONE incoming interrupt will be queued.
So it actually has a diagram indicating that the next SECOND incoming
interrupt will be lost.   This is for interrupt disabled only, per-cpu
(because one CPU one interrupt table).

Does spinlock_irqsave mean I would miss an interrupt? If so,
> spinlock won't be the right thing to do...
>
> What I need is something like:
> while(interrupt_working){ sleep(); }
>
> How to do right?
>
> Kind regards,
> Ole


-- 
Regards,
Peter Teoh

--
To unsubscribe from this list: send an email with
"unsubscribe kernelnewbies" to ecar...@nl.linux.org
Please read the FAQ at http://kernelnewbies.org/FAQ

Reply via email to