Re: list_empty atomic?
From: anish singh
Date: Thu Dec 12 2013 - 15:42:34 EST
On Thu, Dec 12, 2013 at 12:21 PM, Filipe David Manana
<fdmanana@xxxxxxxxx> wrote:
> Hello,
>
> I have a list that is manipulated by several threads. Insert, remove
> and iteration are protected by a lock. Is the locking necessary too
> just for checking if the list is empty, i.e., is list_empty()
> atomic/safe to call without the lock held or not?
Which lock are you taking here?If mutex is used then
you still need to take a lock even when you are checking
the list.Incase of spinlock it depends on the code i.e.
if you are writing interrupt handler and if the interrupt
handler can run on all the cores simultaneously then
you still need to protect it with the spinlock AFICT.
best advice is to just take the damn lock.
>
> thanks
>
> --
> Filipe David Manana,
>
> "Reasonable men adapt themselves to the world.
> Unreasonable men adapt the world to themselves.
> That's why all progress depends on unreasonable men."
>
> _______________________________________________
> Kernelnewbies mailing list
> Kernelnewbies@xxxxxxxxxxxxxxxxx
> http://lists.kernelnewbies.org/mailman/listinfo/kernelnewbies
--
To unsubscribe from this list: send the line "unsubscribe linux-kernel" in
the body of a message to majordomo@xxxxxxxxxxxxxxx
More majordomo info at http://vger.kernel.org/majordomo-info.html
Please read the FAQ at http://www.tux.org/lkml/