Skip site navigation (1)Skip section navigation (2)
Date:      Wed, 29 Mar 2000 22:57:21 -0500 (EST)
From:      Garrett Wollman <wollman@khavrinen.lcs.mit.edu>
To:        Alfred Perlstein <bright@wintelcom.net>
Cc:        Mike Smith <msmith@FreeBSD.ORG>, Matthew Dillon <dillon@apollo.backplane.com>, freebsd-current@FreeBSD.ORG
Subject:   Using packed structs to gain cheap SMP primatives
Message-ID:  <200003300357.WAA89938@khavrinen.lcs.mit.edu>
In-Reply-To: <20000329192526.U21029@fw.wintelcom.net>
References:  <200003300033.QAA07919@mass.cdrom.com> <200003300038.QAA08006@mass.cdrom.com> <20000329192526.U21029@fw.wintelcom.net>

next in thread | previous in thread | raw e-mail | index | archive | help
<<On Wed, 29 Mar 2000 19:25:29 -0800, Alfred Perlstein <bright@wintelcom.net> said:

> What do you guys think about that?  Am I totally missing something
> that makes the Linux way right/ok? (no locking on a 64bit struct)

Generally, it's better to design an optimistic or non-blocking
algorithm rather than twisting data structures to fit some
pre-conceived machine model just to allow atomic updates.  Most
architectures provide either an atomic compare-exchange instruction,
or a ``load linked'' instruction, which is what you need in order to
make this work.

For example, there are good non-blocking algorithms for maintaining a
queue given either LL or compare-exchange of 2*sizeof(pointer).
Unfortunately, this requires strict queue semantics, which few parts
of FreeBSD are designed to make use of.  I've had as a background task
for a while now the creation of a non-blocking equivalent to queue(3),
with as much functionality as is possible to achieve while still
maintaining the non-blocking behavior.

(If you were ever wondering why it was that struct socket and struct
inpcb had grown version numbers: it is for similar reasons.  If I were
only smart enough to figure out how, I would have made all socket and
pcb accesses non-blocking.)

-GAWollman

--
Garrett A. Wollman   | O Siem / We are all family / O Siem / We're all the same
wollman@lcs.mit.edu  | O Siem / The fires of freedom 
Opinions not those of| Dance in the burning flame
MIT, LCS, CRS, or NSA|                     - Susan Aglukark and Chad Irschick


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




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