Re: Working of spinlock_irqsave

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

 



Hi All,

Will this work for multiple writers to solve:

* contention between ISR and write
* contention between 2 or more writers

In the write() method:
Grab spin_lock_irq
Copy from interrupt buffer to local buffer
spin_unlock_irq
copy_to_user from local buffer

If so, How? How is it different from irqsave call?

Regards,
Mukund Jampala


On 4/8/08, bhanu nani <bhanu.lnxnew@xxxxxxxxx> wrote:
> Hi all,
>
> This may be really silly questions which I tried my level best to
> analyse and find answers in grps.
>
> I understand the working of spinlock irqsave as follows, please
> correct me where ever required. When you hold a spinlock with
> spin_lock_irqsave(), it will first store the current interrupt status,
> disable all the interrupts on the CPU which it is running on then it
> tries to acquire the lock.
>
> When releasing, it will release the spinlock, restore the flags using
> stored 'flags' and then reenable the interrupts.
>
> Lets say, I am using spin_lock_irqsave() between ISR and a writer context.
>
> Suppose 2 writers are contending for spinlock. and if the code is as follows:
>
> write()  {
>           spin_lock_irqsave()             /*critical lock    */
>           x++;
>           spin_unlock_irqsave()         /*critical unlock */
> }
>
> If the second writen tries to acquire the lock, when the first writer
> is already holding it, how are flags managed. Will they not get
> overwitten by the second write. when happens when restoring?
>
> I am looking for clarification w.r.t contention between writers rather
> than with ISR.
> I know the 'flags' variable is the one thing that sets the difference
> between spin_lock_irqsave()  & spin_lock_irq().
>
> On an SMP, if the writer has disabled interrupts by acquiring
> respective spinlock and followed by it there occurs an ISR that is
> beng handled bo another CPU, then what? Are we not deadlocking?
>
> Regards,
> Bhanu J
>

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


[Index of Archives]     [Newbies FAQ]     [Linux Kernel Mentors]     [Linux Kernel Development]     [IETF Annouce]     [Git]     [Networking]     [Security]     [Bugtraq]     [Yosemite]     [MIPS Linux]     [ARM Linux]     [Linux RAID]     [Linux SCSI]     [Linux ACPI]
  Powered by Linux