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