number of processors?

Question about which tools to use, bugs, the best way to implement a function, etc should go here. Don't forget to see if your question is answered in the wiki first! When in doubt post here.
Post Reply
mk

number of processors?

Post by mk »

hi,
i want to code a funtion to determine the number of processors. I know the cpuid function, but i found no documentation about the number of processors.
How can i get the number of processors?

thanks for help!

bye,
matze
User avatar
Pype.Clicker
Member
Member
Posts: 5964
Joined: Wed Oct 18, 2006 2:31 am
Location: In a galaxy, far, far away
Contact:

Re:number of processors?

Post by Pype.Clicker »

probably the section about multiprocessors in Intel Manual should provide better information ...
User avatar
Candy
Member
Member
Posts: 3882
Joined: Tue Oct 17, 2006 11:33 pm
Location: Eindhoven

Re:number of processors?

Post by Candy »

mk wrote: I know the cpuid function, but i found no documentation about the number of processors.
How can i get the number of processors?
As you should know, cpuid is local. The only way to get to another CPU is to kickstart it and let it tell for itself (at least, it's the way to get all the working ones in your set). You can do that by sending an IPI to the other processors (type ALL_BUT_ME or such) to start working at a certain address where you put some code that takes a mutex, ups the processor count, releases the mutex (could all be done by a LOCK INC [EBX] or so) and then waits for the main processor to tell it what to do. You wait in the main processor for the number to change (5 secs?) and then display that as count of working processors.

Of course, if you only want to do some statistics stuff, read the APIC settings. They should tell the count.

For info, search on intel for "multiprocessor specification" and/or "APIC" or "IO APIC". The last one I didn't check too far but it should redirect interrupts.
Post Reply