Re: test_and_set_bit() not atomic forever? [cli/sti in char/vt.c [patch]]

Philip Blundell (Philip.Blundell@pobox.com)
Sat, 30 May 1998 21:33:59 +0100


>On Fri, 29 May 1998, Pavel Machek wrote:
>
>>Don't think so. Well, it is safe on i386, but on other architectures,
>>test_and_set_bit is not guaranteed to be atomic. [And I'm afraid that
>
>Arggh I thought that test_and_set_bit() was atomic on all ports (since I
>looked only its i386 implementation)!

It should be -- that's what it's for. It's atomic on Alpha, m68k, ARM,
PPC and MIPS by my reading of the code. I don't really understand Sparc
assembler but it looks to me like it's atomic there too.

There are three different ways you can implement the atomic operation, all
with the same net result. Either you can use atomic test-and-set instructions
that the CPU provides (like m68k does), or you can use load-locked/
store-conditional sequences and a loop (eg Alpha/PPC/MIPS). Finally, for UP
only, you can disable interrupts to ensure atomicity (eg ARM).

Pavel, which port were you thinking of when you said it wasn't atomic?

p.

-
To unsubscribe from this list: send the line "unsubscribe linux-kernel" in
the body of a message to majordomo@vger.rutgers.edu