qemu-devel.nongnu.org archive mirror
 help / color / mirror / Atom feed
From: Jamie Lokier <jamie@shareable.org>
To: qemu-devel@nongnu.org
Subject: Re: [Qemu-devel] Threading Qemu
Date: Wed, 28 May 2008 13:28:50 +0100	[thread overview]
Message-ID: <20080528122850.GC19738@shareable.org> (raw)
In-Reply-To: <483D0C78.8020406@qumranet.com>

Izik Eidus wrote:
> it isn't about just give thread for each virtual CPU, 

> you will need to take care that atomic operations will translate
> from one architecture to another architecture as atomic

That's a bit work, but should be ok provided the host architecture has
equivalent atomic ops, or equal-or-larger-width compare-and-swap
instructions (from which you can make all atomic ops).

Don't forget that simple write ops are atomic on most architectures.
If you have to translate e.g. an 8-byte write to two 4-byte writes on
a 32-bit host, that loses the atomic write property, which many
programs depend on.

> plus you will need to take care for memory barriers, and many more things
> (it looks very complex)

Don't forget _implied_ memory write barrier after every write op on
x86 target.  With x86 target on hosts where writes are not
processor-ordered like x86, you need to put a write-write barrier after
every write - except when you can prove it's not needed.  But that's
really hard.

You can relax this, if you emulate particular x86 targets which have a
"weak write mode".  Some Linux guests, at least, will enable weak
write mode on those - in that mode you can translate to faster code
for the non-x86 host.

Both atomiciy and ordering don't have to be solved if instead you use
"software scheduled" threads on any architecture - e.g. see GNU Pth.
Then you won't get real parallelism on a multiprocessor host, but you
can simulate any multiprocessor target correctly.

-- Jamie

  parent reply	other threads:[~2008-05-28 12:28 UTC|newest]

Thread overview: 7+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2008-05-28  6:31 [Qemu-devel] Threading Qemu mixado
2008-05-28  7:40 ` Izik Eidus
2008-05-28 12:27   ` Fabrice Bellard
2008-05-28 12:39     ` Jamie Lokier
2008-05-28 12:28   ` Jamie Lokier [this message]
2008-05-28 13:31     ` Paul Brook
  -- strict thread matches above, loose matches on Subject: below --
2008-05-28 10:40 Mikael Regnell

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=20080528122850.GC19738@shareable.org \
    --to=jamie@shareable.org \
    --cc=qemu-devel@nongnu.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).