Skip site navigation (1)Skip section navigation (2)
Date:      Tue, 3 Oct 2000 19:51:16 +1100
From:      "Jan Mikkelsen" <janm@transactionsite.com>
To:        "John Baldwin" <jhb@FreeBSD.org>
Cc:        "Kevin Mills" <kmills@aventail.com>, "FreeBSD Hackers" <freebsd-hackers@FreeBSD.org>
Subject:   Re: atomic operations
Message-ID:  <005801c02d17$17efc0a0$0901a8c0@haym.transactionsite.com>

next in thread | raw e-mail | index | archive | help
John Baldwin <jhb@FreeBSD.org> wrote:

>On 03-Oct-00 Jan Mikkelsen wrote:
>> There shouldn't be a need for a loop like the one you describe for a
simple
>> atomic increment.
>
>The trick is that I want to increment and read at the same time.


I don't know the exact semantics of atomic_cmpset_int, but it looks like a
compare and swap operation which returns zero if the operation failed, some
other value on success.

Unless I've missed something, the basic operation of your loop can be done
(on a '486 or better) without the loop by using the xadd instruction.  Of
course, if the code needs to run on earlier processors, xadd fails and a
loop is necessary.

Jan Mikkelsen




To Unsubscribe: send mail to majordomo@FreeBSD.org
with "unsubscribe freebsd-hackers" in the body of the message




Want to link to this message? Use this URL: <https://mail-archive.FreeBSD.org/cgi/mid.cgi?005801c02d17$17efc0a0$0901a8c0>