I have an SMP-related issue that I am...
Articles and Tips: qna
01 May 2003
Q.
I have an SMP-related issue that I am trying to track down. I need to know which CPU is executing my NLM code. The code might be a CLIB thread, or an ESR or ISR routine which may be called directly from a hardware interrupt-driven event, so something that is low-level/low impact, like inspecting hardware or processor registers, would be preferable.
A.
Here are three functions that give processor information:
typedef void * THREAD; typedef unsigned long PROCESSOR;
/* read only variable */ extern PROCESSOR CpuCurrentProcessor;
extern THREAD kCurrentThread(void); extern PROCESSOR kCurrentThreadBinding( THREAD ThreadHandle ); extern PROCESSOR kReturnCurrentProces sorID(void);
int main(int argc, char *argv[]) { (void)argc; (void)argv;
printf("Running on processor %d\n", CpuCurrentProcessor); printf("Running on processor %d\n", kCurrentThreadBinding(kCurrentThread())); printf("Running on processor %d\n", kReturnCurrentProcessorID()); }
The kCurrentThreadBinding function probably doesn't do what you're looking for, since it actually returns the thread's processor binding rather than the processor it is active on and the thread may not be bound to a specific processor.
These are not CLib APIs, they are part of the MPK library. These interfaces aren't exposed, so an NLM that uses them can't be certified. It would also be possible to get this information by calling netware_cpu_info iteratively. Inside the structure, there is a Boolean that tells whether, for the given CPU, it is the one executing the call.
* Originally published in Novell AppNotes
Disclaimer
The origin of this information may be internal or external to Novell. While Novell makes all reasonable efforts to verify this information, Novell does not make explicit or implied claims to its validity.