qemu-devel
[Top][All Lists]
Advanced

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

Re: [Qemu-devel] [PATCH] use a thread id variable


From: Jamie Lokier
Subject: Re: [Qemu-devel] [PATCH] use a thread id variable
Date: Sun, 9 Mar 2008 11:58:26 +0000
User-agent: Mutt/1.5.13 (2006-08-11)

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.

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.

What you're supposed to do with pthreads in general is use pthread_self().

Btw, unfortunately pthread_self() is not safe to call from signal
handlers.

-- Jamie




reply via email to

[Prev in Thread] Current Thread [Next in Thread]