lkml.org 
[lkml]   [2003]   [May]   [18]   [last100]   RSS Feed
Views: [wrap][no wrap]   [headers]  [forward] 
 
Messages in this thread
/
Date
From
SubjectRe: recursive spinlocks. Shoot.
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/

\
 
 \ /
  Last update: 2005-03-22 13:35    [W:1.245 / U:1.724 seconds]
©2003-2020 Jasper Spaans|hosted at Digital Ocean and TransIP|Read the blog|Advertise on this site