qemu-devel.nongnu.org archive mirror
 help / color / mirror / Atom feed
From: "Glauber Costa" <glommer@gmail.com>
To: Gilad Ben-Yossef <gilad@codefidence.com>
Cc: kvm-devel@lists.sourceforge.net, chrisw@sous-sol.org,
	qemu-devel@nongnu.org, Glauber Costa <gcosta@redhat.com>
Subject: Re: [Qemu-devel] [PATCH] use a thread id variable
Date: Mon, 17 Mar 2008 14:55:03 -0300	[thread overview]
Message-ID: <5d6222a80803171055g260d6742u72c82876403758c6@mail.gmail.com> (raw)
In-Reply-To: <47D3F9AF.2030408@codefidence.com>

On Sun, Mar 9, 2008 at 11:52 AM, Gilad Ben-Yossef <gilad@codefidence.com> wrote:
> Jamie Lokier wrote:
>  > Gilad Ben-Yossef wrote:
>  >> Glauber Costa wrote:
>  >>> This patch introduces a "thread_id" variable to CPUState.
>  >>> It's duty will be to hold the process, or more generally, thread
>  >>> id of the current executing cpu
>  >>>
>  >>>     env->nb_watchpoints = 0;
>  >>> +#ifdef __WIN32
>  >>> +    env->thread_id = GetCurrentProcessId();
>  >>> +#else
>  >>> +    env->thread_id = getpid();
>  >>> +#endif
>  >>>     *penv = env;
>  >> hmm... maybe I'm missing something, but in Linux at least I think you
>  >> would prefer this to be gettid() rather then getpid as each CPU has it's
>  >> own thread, not a different process.
>  >
>  > On most platforms, getpid() returns the same value for all threads, so
>  > it's not useful as a thread id.
>
>  Of course it does - this what POSIX says it should do (Linux 2.4 in
>  compliance not withstanding). Which is why I suggested to use on Linux
>  the non standard gettid() rather then getpid
>
> >
>  > On Linux, it depends which version of threads.  The old package,
>  > LinuxThreads, has different getpid() for each thread.  The current one,
>  > NPTL, has them all the same.
>
>
>  LinuxThreads behavior is wrong according to the POSIX standard. Of
>  course, nothing else was possible with 2.4 kernels, so this is not an
>  error on LinuxThreads coders part.
>
>
>
>  > What you're supposed to do with pthreads in general is use pthread_self().
>
>  Unfortunately, AFAIK the opaque handle that pthread_self() returns is
>  not  quite meaningless outside of the process whereas what the non
>  standard gettid() returns can actually be used to identify a thread from
>  "outside" the process, like the shell.
>

Identifying a thread from the outside world is _exactly_ my intent
here, so pthread_self won't do.

I can easily write a wrapper to gettid() and use it. It would make the
kvm specific patch not-necessary, which is good.

The reason I used getpid in the first place, is that all raw qemu cpus
are in the same process anyway.

It's up to you, guys.

-- 
Glauber Costa.
"Free as in Freedom"
http://glommer.net

"The less confident you are, the more serious you have to act."

  parent reply	other threads:[~2008-03-17 17:55 UTC|newest]

Thread overview: 14+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2008-03-05 20:01 [Qemu-devel] [PATCH 0/3] Expose thread id through info cpus Glauber Costa
2008-03-05 20:01 ` [Qemu-devel] [PATCH] use a thread id variable Glauber Costa
2008-03-05 20:01   ` [Qemu-devel] [PATCH] augment info cpus Glauber Costa
2008-03-05 20:01     ` [Qemu-devel] [PATCH] KVM: use actual thread id for vcpus Glauber Costa
2008-03-09  9:26   ` [Qemu-devel] [PATCH] use a thread id variable Gilad Ben-Yossef
2008-03-09 11:58     ` Jamie Lokier
2008-03-09 14:52       ` Gilad Ben-Yossef
2008-03-09 16:12         ` M. Warner Losh
2008-03-17 17:55         ` Glauber Costa [this message]
2008-03-09 16:09       ` M. Warner Losh
2008-03-09 20:01         ` Jamie Lokier
2008-03-09 16:23     ` [kvm-devel] " Daniel P. Berrange
2008-03-05 20:07 ` [Qemu-devel] Re: [PATCH 0/3] Expose thread id through info cpus Glauber Costa
2008-03-06  6:55 ` Avi Kivity

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=5d6222a80803171055g260d6742u72c82876403758c6@mail.gmail.com \
    --to=glommer@gmail.com \
    --cc=chrisw@sous-sol.org \
    --cc=gcosta@redhat.com \
    --cc=gilad@codefidence.com \
    --cc=kvm-devel@lists.sourceforge.net \
    --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).