[Gllug] Atomic increment/decrement
Jonathan Dye
jonathan.dye at automationpartnership.com
Wed Aug 7 13:52:51 UTC 2002
> -----Original Message-----
> From: t.clarke [mailto:tim at seacon.co.uk]
> Sent: 07 August 2002 14:40
> To: gllug at linux.co.uk
> Subject: [Gllug] Atomic increment/decrement
>
>
> I have no ideas about mutexes - never fortunately had the need.
>
> But I do remember many years ago having to do something
> vaguely similar on
> a TI990 computer.
>
> As I recall, the fundamental issue was one of getting the CPU
> to do an atomic
> operation (of any sort) by first using a atomic 'test and
> set' cpu opcode.
> The routine was in assembler and did something along the lines of
> test and set a flag word
> if the set succeeded you have control so do the atomic operation
> and reset the flag word
> if no success spin for a bit and try again
>
> The whole thing depended on an atomic cpu test-and-set
> instruction and was
> written in assembler.
>
> I assume that unless the C language supports such a
> test-and-set cpu instruction
> directly, you will have do write something in assembler to
> gain access to the
> Intel X86 opcodes directly.
It's not supported by the c lanugage but it is somtimes a system call that
is implemented in the kernel so that you can have atomicity (is that a
word?) across threads/processes/processors. It would probably be done using
atomic cpu instructions (or with kernel locks).
JD
> Tim
_____________________________________________________________________
This message has been checked for all known viruses by the
MessageLabs Virus Scanning Service
--
Gllug mailing list - Gllug at linux.co.uk
http://list.ftech.net/mailman/listinfo/gllug
More information about the GLLUG
mailing list