9fans - fans of the OS Plan 9 from Bell Labs
 help / color / mirror / Atom feed
From: "Russ Cox" <rsc@swtch.com>
To: matthiasb@acm.org, 9fans@cse.psu.edu
Subject: Re: [9fans] amd64 support in p9p?
Date: Thu,  2 Mar 2006 18:27:23 -0500	[thread overview]
Message-ID: <79a03ecc1c3386985559c25f009f1d95@swtch.com> (raw)
In-Reply-To: <20060302231511.GA11050@pestilenz.org>

> is there anybody interested in helping to port the
> plan9 from user space to amd64/x86_64?
> The most platform dependend code seems to be the libthread
> stuff. On OpenBSD-amd64 I can borrow an assembler version of
> rfork_thread from the OpenBSD librthread and can improvise
> the _tas function. The get/setmcontext pose a problem because
> I do not know if struct ucontext must really be exactly the same
> as struct sigcontext.

Which operating system are we talking about?

If the operating system provides:
	- a pthreads that doesn't use the high bits of the stack pointer
	   as the per-pthread register
	- working makecontext, getcontext, setcontext

then all you have to write is a _tas function, and on the x86_64
you should just use the 386 one unmodified (see Linux-386-asm.s)

If the OS does not provide a working makecontext, getcontext,
and setcontext, then you need to write those too.  They needn't
follow any structures laid down by the rest of the system.
They just have to match each other.  For example, power-ucontext.h
is just made up from scratch.  It just needs to be a register set and
match the assembly.

If the OS does not provide a pthreads with a real per-thread register
then you are in bigger trouble and have to provide an entire kernel
thread implementation.  I doubt very much you need to do this on
any x86-64.  The only people who made this mistake seem to be
the early implementers of 386 thread libraries (these broken
libraries are still in use on NetBSD, OpenBSD, and Linux pre-NPTL),
and that's necessitated by the small number of registers.  On x86-64,
there's no reason to make that mistake.

In short, you probably don't need to write rfork_thread, you might need
to write getcontext/setcontext, and you can just steal _tas.

Russ



  parent reply	other threads:[~2006-03-02 23:27 UTC|newest]

Thread overview: 5+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2006-03-02 23:15 plan9
2006-03-02 23:23 ` Devon H. O'Dell
2006-03-02 23:27 ` Russ Cox [this message]
2006-03-02 23:51   ` Ronald G Minnich
2006-03-02 23:56 ` Tim Wiess

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=79a03ecc1c3386985559c25f009f1d95@swtch.com \
    --to=rsc@swtch.com \
    --cc=9fans@cse.psu.edu \
    --cc=matthiasb@acm.org \
    /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).