Skip site navigation (1)Skip section navigation (2)
Date:      Mon, 10 Mar 2003 13:26:17 -0500 (EST)
From:      John Baldwin <jhb@FreeBSD.org>
To:        Poul-Henning Kamp <phk@phk.freebsd.dk>
Cc:        src-committers@FreeBSD.org, cvs-src@FreeBSD.org, Nate Lawson <nate@root.org>
Subject:   Re: cvs commit: src/sys/sys devicestat.h
Message-ID:  <XFMail.20030310132617.jhb@FreeBSD.org>
In-Reply-To: <2986.1047320558@critter.freebsd.dk>

next in thread | previous in thread | raw e-mail | index | archive | help

On 10-Mar-2003 Poul-Henning Kamp wrote:
> In message <Pine.BSF.4.21.0303101009420.93727-100000@root.org>, Nate Lawson wri
> tes:
> 
> Doesn't work:
> 
>       CPU0 (kernel)           CPU1 (userland)
> 
>       increment seq
>                               start copy
>       fiddle data
>                               end copy
>                               (copy is inconsistent)
> 
> You need two sequence fields:
> 
>       CPU0 (kernel)           CPU1 (userland)
> 
>       increment seq0
>                               start copy
>       fiddle data
>                               end copy
>       increment seq1
>                               (seq0 != seq1 indicates inconcistent data)
> 
> Notice that to make it absolutely water-tight, the seq fields must
> be updated with appropriate write barriers and the order of the
> fields must be the opposite as the direction the copy is performed in.

Correct.  If you use:

        atomic_add_acq_int(&seq0, 1);
        ... all the updates ...
        atomic_add_rel_int(&seq1, 1);

then you should have sufficient membars.

-- 

John Baldwin <jhb@FreeBSD.org>  <><  http://www.FreeBSD.org/~jhb/
"Power Users Use the Power to Serve!"  -  http://www.FreeBSD.org/

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




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