9fans - fans of the OS Plan 9 from Bell Labs
 help / color / mirror / Atom feed
From: David Leimbach <leimy2k@gmail.com>
To: Fans of the OS Plan 9 from Bell Labs <9fans@9fans.net>
Subject: Re: [9fans] plan9 go output faults on 9vx with rfork
Date: Thu, 20 Jan 2011 08:48:44 -0800	[thread overview]
Message-ID: <AANLkTi=KO4VciQZJAKXF2D8hiMbSQWnYL8_mrfk4NoqF@mail.gmail.com> (raw)
In-Reply-To: <AANLkTi=OE2_rZ=ktiw-Rq0c0cHYZVBu9EVtoXhA_UY0z@mail.gmail.com>

[-- Attachment #1: Type: text/plain, Size: 2893 bytes --]

On Wed, Jan 19, 2011 at 10:59 PM, ron minnich <rminnich@gmail.com> wrote:

> OK, Pavel sent me a nice piece of code that implements cmpswap using a
> gcc trick. I did not want to use the trick for a few reasons, and
> thought to use futex instead, as it seemed appropriate. Weirdly
> enough, I can not find a simple implementation of cmpswap that uses
> futex, though I can find several papers describing how tricky futex
> is, and one Linux person who told me that futex had evolved in ways
> not necessarily to our advantage.
>
> Every time I'm ready to throw in the towel on Plan 9 and just go with
> Linux I hit something like futex and it's back into the fray ... :-)
>

Actually the mutex implementations I've seen with futex use cmpswap.  Also
my understanding of futex is that it's just an API for a portion of what
needs to be done to implement a fast user space mutex. Essentially you have
to examine the value in user space, see that it's what you expect and move
on unblocked.  If the value differs from what is expected, you must block,
and wait.  This is why they're "tricky" :-).

I do not see anything immediately wrong with using the compiler intrinsic
functions that are supported pretty well across GNU, clang, Intel C/C++ and
I think even Microsoft's compilers.  I do think that gcc does not implement
them for i386, or if it does, it does so with a library routine instead of
the compiler just generating the assembly for that architecture's version.

I've run smack into this problem myself just about 8 months ago, and it was
due to Boost being built with a mismatched architecture from some other code
that was built with another.  The result was that since these builtins get
resolved sometimes at link time, and sometimes at compile time, they don't
behave like normal functions, and you get a mess.

You've got to pick one mess, or implement your own multi-architecture
library of cmpswap and like routines :-).


>
> So, I have committed changes to my vx32 repo and Pavel's sieve now
> works on 9vx on a 32-bit linux vmware image. It should also work if
> you build on freebsd. It should also work if you build on 64-bit linux
> but there are no guarantees, since all this relies on some gcc
> builtins.
>
> You can see what I've done if you look at my repo.
>
> BTW, the sieve ran to 17xxx on linux and then I got some kind of
> malloc failure, I'll assume it's another 32-bit gc issue. I'm up to
> 57917 on osx.
>

If your compiler is generating code for -march=i386, you could see some
funny stuff on 32bit platforms.  Better to use -march=i686.  Might not come
up, but it's something to look for.

I really need to try this version of 9vx sometime instead of just thinking
about it :-)

Dave


>
> You're going to need Pavel's mods to go, I suppose. but that's another
> story ...
>
> ron
>
>

[-- Attachment #2: Type: text/html, Size: 3690 bytes --]

  reply	other threads:[~2011-01-20 16:48 UTC|newest]

Thread overview: 21+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
     [not found] <AANLkTikJ3y5exFtTic+8dhUsUqeZBDmR=S-8VzKDK0GH@mail.gmail.com>
     [not found] ` <AANLkTink4CrELJfGf3W15caSYX8Se5ygsm_WeMRdCBz=@mail.gmail.com>
     [not found]   ` <AANLkTikUa1KF+8NP54BHicus++YbeZbD48E7z=1H0Y5V@mail.gmail.com>
     [not found]     ` <AANLkTinAe_r2EbqOHZGVjaN8yDbhja0m5MUuJfMrn6Cs@mail.gmail.com>
2011-01-20  6:59       ` ron minnich
2011-01-20 16:48         ` David Leimbach [this message]
     [not found]         ` <AANLkTintaOjTpC6Eaz3Ka7256KXYzaDeYg3jsqbCT5Wx@mail.gmail.com>
     [not found]           ` <AANLkTim3MH0t6H1522DnHf-P_E7a0rtt6FzY9f3ti10i@mail.gmail.com>
     [not found]             ` <AANLkTi=1btTKGVd_gKk+abAjTEwsEPMBhP4L3agrDubg@mail.gmail.com>
     [not found]               ` <AANLkTimuhE_G46f0J3nRBos1kVSDvTvUwvUb8u0RsR4A@mail.gmail.com>
     [not found]                 ` <AANLkTiki2v5MgdxwgjQpJopnrRQhBXKm80+aua_FFAef@mail.gmail.com>
     [not found]                   ` <AANLkTi=fi2Xm0R1Jx2NcrKUkyJaYqnizDP0xJPgaenMY@mail.gmail.com>
2011-01-23  2:43                     ` ron minnich
2011-01-23  2:48                       ` erik quanstrom
2011-01-23  2:56                         ` ron minnich
2011-01-23  3:00                           ` erik quanstrom
2011-01-23 19:20                             ` Charles Forsyth
2011-01-23 19:15                               ` Devon H. O'Dell
2011-01-23 20:40                                 ` EBo
2011-01-23 22:00                                   ` ron minnich
2011-01-24 12:11                                     ` EBo
2011-01-24 17:18                                     ` yy
2011-01-24 17:24                                       ` erik quanstrom
2011-01-25 14:28                                         ` Richard Miller
2011-01-24 17:24                                       ` ron minnich
2011-02-08  0:05                                         ` yy
2011-01-24 20:02                                       ` Steve Simon
2011-01-23 23:40                                   ` Charles Forsyth
2011-01-24  1:18                                     ` ron minnich
2011-01-24 12:17                                       ` EBo
2011-01-24 17:16                                         ` ron minnich

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='AANLkTi=KO4VciQZJAKXF2D8hiMbSQWnYL8_mrfk4NoqF@mail.gmail.com' \
    --to=leimy2k@gmail.com \
    --cc=9fans@9fans.net \
    /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;
as well as URLs for NNTP newsgroup(s).