Someone can clarify my understanding? On Fri, Aug 27, 2010 at 5:03 AM, vinit dhatrak <[email protected]>wrote:
> > > On Wed, Aug 25, 2010 at 1:18 AM, Lal <[email protected]> wrote: > >> Is below code race free? >> >> void process_context_function(void) >> { >> /* interrupts enabled here */ >> spin_lock(&lock); >> modify_critical_section_list(); >> spin_unlock(&lock); >> } >> >> irqreturn_t a2091_intr (int irq, void *_instance) >> { >> if(spin_trylock(&lock)) { >> modify_critical_section_list(); >> spin_unlock(&lock); >> } >> else { >> /* skip */ >> } >> >> return IRQ_HANDLED; >> } >> >> >> More specifically, can spin_lock & spin_trylock have race? >> >> > Hi Lal, > > Looks like you have a critical section between process context and > interrupt context, right? > Then why not just use spin_lock_irq () ? You will not need trylock in that > case. > > Here is the similar discussion where your approach is discussed, > > http://www.geeksofpune.in/drupal/?q=node/75 > > From comments, looks like it is not correct to use trylock on UP. > > Please refer famous article here, > http://www.kernel.org/pub/linux/kernel/people/rusty/kernel-locking/c214.html#MINIMUM-LOCK-REQIREMENTS > > >From the above "Unreliable guide to locking", assuming it is reasonably reliable :-), how do u read the column "User COntext A"? (ie, what does no entries means?) <http://www.mjmwired.net/kernel/Documentation/spinlocks.txt> > -Vinit > > > >> Regards >> Lal >> >> -- >> To unsubscribe from this list: send an email with >> "unsubscribe kernelnewbies" to [email protected] >> Please read the FAQ at http://kernelnewbies.org/FAQ >> >> > -- Regards, Peter Teoh
