On Wed, Aug 25, 2010 at 1:18 AM, Lal <learner.kernel@xxxxxxxxx> 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,
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
-Vinit
Regards
Lal
--
To unsubscribe from this list: send an email with
"unsubscribe kernelnewbies" to ecartis@xxxxxxxxxxxx
Please read the FAQ at http://kernelnewbies.org/FAQ