Re: GetCurrentProcessorNumber() for XP?



That shall only work on kernel mode.

"frank" <frank@xxxxxxxxxxxxxxxxxxxxxxxxx> wrote in message
news:DB239684-C416-462A-9D78-DC8BD99036B8@xxxxxxxxxxxxxxxx

take a look in <ntdd.h>

...

//
// Get the current processor number
//

__inline ULONG KeGetCurrentProcessorNumber(VOID)
{
__asm { movzx eax, _PCR KPCR.Number }
}

with

#define _PCR fs:[0]

...



"Ron Kuper" wrote:

We need a way to tell which logical processor the current thread is
running
on. I see that GetCurrentProcessorNumber() exists but only for Server
2003
and Vista. We need an API like this on Win XP.

I did some web searching and learned that there is a way to do this using
CPUID, by manipulating the APIC ID and also knowing the number of
physical
processors and number of cores per processor. However there is no clear
cookbook example that does exactly what GetCurrentProcessorNumber() does.

Does anyone have any pointers or code fragments for doing this?



.