On 08/25/2010 01:18 AM, Lal wrote:
Is below code race free?
Ironically, it is safe on SMP, but not on UP !
As the other poster noted, spin_lock is a NOOP on
UP kernels, which means that the irq handler could
be called during your modify_critical_section_list()
call in process context.
The other poster also provided the solution - using
spin_lock_irq & spin_unlock_irq in the process context
function.
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;
}
--
To unsubscribe from this list: send an email with
"unsubscribe kernelnewbies" to [email protected]
Please read the FAQ at http://kernelnewbies.org/FAQ