Re: which processor is a thread executing on?
Re: which processor is a thread executing on?
- Subject: Re: which processor is a thread executing on?
- From: Wade Tregaskis <email@hidden>
- Date: Wed, 01 Oct 2008 18:59:28 -0700
I am writing a multi-threaded app, and I would like to know which
processor the thread is executing on.
Is there a pthread function call to determine this?
There is not. As Andreas noted, you can't do this reliably without
being forcefully bound to a particular CPU, in which case you already
know, and which is strongly discouraged in any case.
You can do it, though. You can execute CPUID and figure it out from
there. But CPUID is a very expensive little instruction - it takes
something like ~100ns to execute on today's machines, and has other
side-effects - so you don't want to call it too often.
But the most pertinent question, really, is why you want to do this?
Either there's a better way to do whatever you're ultimately trying to
do, or it's something that you should file an enhancement request for,
if it's worth doing.
Wade
_______________________________________________
Do not post admin requests to the list. They will be ignored.
Darwin-kernel mailing list (email@hidden)
Help/Unsubscribe/Update your Subscription:
This email sent to email@hidden