From: postgresql_2016@163.com <postgresql_2016@163.com>
To: pgsql-docs@postgresql.org
Subject: 【memory barrier】Should we update the README.barrier description.
Date: Sat, 9 May 2020 18:01:05 -0700 (MST)
Message-ID: <1589072465169-0.post@n3.nabble.com> (raw)
Hi
When I read the introduction of Weaknesses of Memory Barriers in
README.barrier, the following maybe out-of-date now.
Even very simple write operations often require additional synchronization.
For example, it's not safe for multiple writers to simultaneously execute
this code (supposing x is a pointer into shared memory):
x->foo++;
Although this may compile down to a single machine-language instruction,
the CPU will execute that instruction by reading the current value of foo,
adding one to it, and then storing the result back to the original address.
If two CPUs try to do this simultaneously, both may do their reads before
either one does their writes. *Eventually we might be able to use an atomic
fetch-and-add instruction for this specific case on architectures that
support
it, but we can't rely on that being available everywhere, and we currently
have no support for it at all. Use a lock.*
Now, the postgres has support atomic operation and use it, in some cases we
have not use the lock.
--
Sent from: https://www.postgresql-archive.org/PostgreSQL-docs-f2165602.html
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Reply to all the recipients using the --to and --cc options:
reply via email
To: pgsql-docs@postgresql.org
Cc: postgresql_2016@163.com
Subject: Re: 【memory barrier】Should we update the README.barrier description.
In-Reply-To: <1589072465169-0.post@n3.nabble.com>
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
This inbox is served by DDX for PostgreSQL; see mirroring instructions
for how to clone and mirror all data and code used for this inbox