list_empty atomic?

anish singh anish198519851985 at gmail.com
Thu Dec 12 15:42:28 EST 2013


On Thu, Dec 12, 2013 at 12:21 PM, Filipe David Manana
<fdmanana at gmail.com> 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 at kernelnewbies.org
> http://lists.kernelnewbies.org/mailman/listinfo/kernelnewbies



More information about the Kernelnewbies mailing list