From: skaller <skaller@users.sourceforge.net>
To: David Brown <caml-list@davidb.org>
Cc: Ker Lutyn <ker527mail@yahoo.com>, caml-list <caml-list@inria.fr>
Subject: Re: [Caml-list] atomicity guarantees for threaded code
Date: 30 Oct 2004 11:07:28 +1000 [thread overview]
Message-ID: <1099098448.11063.284.camel@pelican.wigram> (raw)
In-Reply-To: <20041030003249.GA11524@old.davidb.org>
On Sat, 2004-10-30 at 10:32, David Brown wrote:
> On Sat, Oct 30, 2004 at 09:54:37AM +1000, skaller wrote:
>
> > > As long as the reference write is atomic, which it is going to be, I would
> > > suspect this is safe. It probably would even be safe if multiple threads
> > > updated the reference, but you might just drop entries.
> >
> > It isn't clear though. On x86 you can have 1 byte alignment
> > for an address. What happens if:
>
> But, a reference in ocaml will always be in a block, which will always be
> aligned.
On what boundary?
> Even x86 will be atomic with a 32-bit transfer that is aligned.
But perhaps not a 64 bit one.
Part of my argument was that it is implementation
dependent. In particular, a page fault is only one
kind of interrupt. It is possible, for example,
to get another IRQ right in the middle of a transfer
from memory .. and interrupt the transfer. And that
IRQ could actually cause the page from which the
load was occuring to be swapped out .. meaning
it may not be necessary to be near a page boundary
to get a page fault... and thus the alignment
may not matter.
As I indicated some instructions on some processors
aren't atomic, particularly CISC machines.. it may be
that loading and storing isn't such an interruptible
instruction, but I'm not sure .. without checking
the x86 hardware manual. Certainly 48 bit loads
on a x386 can cause segmentation faults (I mean,
the whole thing is *designed* to do that) .. however
these don't normally apply to Unix like systems that
aren't capable of using segmented addressing
(in user space).
So I would guess you are right for all OS Ocaml supports.
Even so I'd be loath to rely on such a guess until
the Ocaml team asserted the guarrantee in the manual.
I wouldn't do it in C, because of the wide class
of platforms it applies to .. but Ocaml doesn't intend
to handle such a wide class.
If the guarrantee was made, it could simplify some
Ocaml programming significantly, and thus possibly
improve performance.
--
John Skaller, mailto:skaller@users.sf.net
voice: 061-2-9660-0850,
snail: PO BOX 401 Glebe NSW 2037 Australia
Checkout the Felix programming language http://felix.sf.net
next prev parent reply other threads:[~2004-10-30 1:07 UTC|newest]
Thread overview: 7+ messages / expand[flat|nested] mbox.gz Atom feed top
2004-10-29 16:39 Ker Lutyn
2004-10-29 21:50 ` [Caml-list] " David Brown
2004-10-29 23:54 ` skaller
2004-10-30 0:32 ` David Brown
2004-10-30 1:07 ` skaller [this message]
2004-10-30 2:07 ` David Brown
2004-10-30 2:36 ` skaller
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
Avoid top-posting and favor interleaved quoting:
https://en.wikipedia.org/wiki/Posting_style#Interleaved_style
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to=1099098448.11063.284.camel@pelican.wigram \
--to=skaller@users.sourceforge.net \
--cc=caml-list@davidb.org \
--cc=caml-list@inria.fr \
--cc=ker527mail@yahoo.com \
/path/to/YOUR_REPLY
https://kernel.org/pub/software/scm/git/docs/git-send-email.html
* If your mail client supports setting the In-Reply-To header
via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line
before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox