lkml.org 
[lkml]   [1996]   [Oct]   [17]   [last100]   RSS Feed
Views: [wrap][no wrap]   [headers]  [forward] 
 
Messages in this thread
/
Date
From
SubjectRe: Could this become a race condition?


On Wed, 16 Oct 1996, Matti Aarnio wrote:
>
> > Hi,
> >
> > in /usr/src/linux/include/linux/locks.h of kernel 2.0.21, I can see :
> >
> > extern inline void lock_super(struct super_block * sb)
> > {
> > if (sb->s_lock)
> > __wait_on_super(sb);
> > sb->s_lock = 1;
> > }
> ...
> .. is there a deadlock ? ..
> ...
> > Is there any way to avoid that?
>
> Yes. Yes:
>
> while (set_bit(1,&sb->s_lock) != 0)
> __wait_on_super(sb);
>
> While the old value of the s_lock is non-zero, call
> __wait_on_super(), else leave with s_lock set.
> See <asm/bitops.h> for the routines.

Actually, the old code is not a race condition, because "sb_lock" is only
modified in a "process context" and never from interrupts. As such, the
general non-re-entrancy of the kernel will guarantee that you can do
"atomic" operations like the above without using the setbit() etc atomic
stuff

Linus

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