Re: Atomic Operations

From: Alvaro Herrera <alvherre(at)commandprompt(dot)com>
To: Markus Schiltknecht <markus(at)bluegap(dot)ch>
Cc: pgsql-hackers(at)postgresql(dot)org
Subject: Re: Atomic Operations
Date: 2007-01-10 19:21:47
Message-ID: 20070110192147.GB15378@alvh.no-ip.org
Views: Raw Message | Whole Thread | Download mbox | Resend email
Thread:
Lists: pgsql-hackers

Markus Schiltknecht wrote:

Hi Markus,

> what are the assumptions PostgreSQL normally does about atomic
> operations? I see sig_atomic_t is used in signal handlers. Additionally,
> there is a match for a cmpxchg instruction in some solaris ports code,
> but that's about what I found in the source.
>
> Am I safe assuming that pointer assignments are atomic (on all platforms
> PostgreSQL compiles on, that is)? (This is a 'practical advice' from the
> GNU Libc Manual) How about other integers smaller or equal in size to
> sizeof(sig_atomic_t)?
>
> I'm asking to make sure I rely on the same guarantees in my code.

Currently we rely on TransactionId being atomic; see
GetNewTransactionId. It's defined as uint32 somewhere, so I guess you
could rely on that.

--
Alvaro Herrera http://www.CommandPrompt.com/
PostgreSQL Replication, Consulting, Custom Development, 24x7 support

In response to

Browse pgsql-hackers by date

  From Date Subject
Next Message Stefan Kaltenbrunner 2007-01-10 19:22:20 Re: ECPG regression test failures on Solaris 10/x86_64
Previous Message Stefan Kaltenbrunner 2007-01-10 18:38:42 Re: [PATCHES] fix build on Solaris 10/x86_64 in 64bit mode with Sun