Re: recursive spinlocks. Shoot.

From: Davide Libenzi (davidel@xmailserver.org)
Date: Sun May 18 2003 - 18:26:26 EST


On Mon, 19 May 2003, Peter T. Breuer wrote:

> No. This is not true. Imagine two threads, timed as follows ...
>
> .
> .
> .
> .
> if ((snl)->uniq == current) {
> atomic_inc(&(snl)->count); .
> } else { .
> spin_lock(&(snl)->lock); .
> atomic_inc(&(snl)->count); .
> (snl)->uniq = current; <-> if ((snl)->uniq == current) {
> atomic_inc(&(snl)->count);
> } else {
> spin_lock(&(snl)->lock);
> atomic_inc(&(snl)->count);
> (snl)->uniq = current;
>
>
> There you are. One hits the read exactly at the time the other does a
> write. Bang.

So, what's bang for you ? The second task (the one that reads "uniq")
will either see "uniq" as NULL or as (task1)->current. And it'll go
acquiring the lock, as expected. Check it again ...

- Davide

-
To unsubscribe from this list: send the line "unsubscribe linux-kernel" in
the body of a message to majordomo@vger.kernel.org
More majordomo info at http://vger.kernel.org/majordomo-info.html
Please read the FAQ at http://www.tux.org/lkml/



This archive was generated by hypermail 2b29 : Fri May 23 2003 - 22:00:32 EST