Messages in this thread |  | | Subject | Re: Could this become a race condition? | Date | Thu, 17 Oct 1996 19:10:01 +0300 (EET DST) | From | Matti Aarnio <> |
| |
Linus comments at my answer on the list: > > .. 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
Indeed, however I have understood that a long-term goal is to get the SMP locks deeper/wider into the kernel from current SINGLE spin-lock at system-call entrance. That way there can be multiple processors running in kernel, and thus having a need for this kind of atomic stuff.
> Linus
/Matti Aarnio <matti.aarnio@tele.fi>
|  |