Re: Locks used in the FAT file system are non-atomic and in fact, don't work on SMP systems

Alan Cox (alan@lxorguk.ukuu.org.uk)
Thu, 26 Aug 1999 19:01:23 +0100 (BST)


> Lock()
> {
> while (lock) sleep_on(&wait);
> lock =3D 1;
> }
>
> Unlock()
> {
> lock =3D 0;
> wake_up(&wait);
> }
>
> Two processes can enter Lock() while lock is equal to 0, and both set =
> it. We have seen this occur, and it seems broken. =20

Really

CPU 0 CPU 1
while(lock) - its 0 while(lock) - its 0
lock=1 lock=1

am I missing something. I think you want to be using atomic test and set
operations. (test_and_set_bit)

Alan

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