Skip site navigation (1)Skip section navigation (2)
Date:      Sat, 22 Mar 2003 12:48:39 -0700
From:      "Justin T. Gibbs" <gibbs@scsiguy.com>
To:        Poul-Henning Kamp <phk@phk.freebsd.dk>, Bakul Shah <bakul@bitblocks.com>
Cc:        arch@freebsd.org
Subject:   Re: memcpy() with specified direction of copying ? 
Message-ID:  <8980000.1048362518@aslan.btc.adaptec.com>
In-Reply-To: <9531.1047848405@critter.freebsd.dk>
References:   <9531.1047848405@critter.freebsd.dk>

next in thread | previous in thread | raw e-mail | index | archive | help
> Well, in my case it is a matter of shared memory where the order in
> which I snapshot a data structure is critical for detecting integrity
> issues.

Without memory barriers, the order is undefined on many cpus irrespective
of the direction of copy.  So, for a data structure like this:

	start_tag
	some data
	...
	end_tag

A client knows that the data is stable if start_tag and end_tag are
equal only if the data is written as:

	start_tag = new_tag;
	mb();
	Fill the middle in whatever order is convenient;
	mb();
	end_tag = new_tag;

--
Justin


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




Want to link to this message? Use this URL: <https://mail-archive.FreeBSD.org/cgi/mid.cgi?8980000.1048362518>