Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

How can I detect the number of cores in x86 assembly?

I am writing a very simple operating system as a learning tool for myself. My current task is detecting as much about the hardware as possible.

I have so far been able to find a lot of information about the CPU using the CPUID instruction. The one thing I can't seem to find is the number or physical and/or logical cores. Is there a way to do this using a combination of x86 assembly and C?

I am writing the operating system, so the code can be run in supervisor mode, and there are no system libraries to query for this information.

like image 753
Conlan Avatar asked May 26 '11 22:05

Conlan


People also ask

How can I know the number of my Cores?

Press Ctrl + Shift + Esc to open Task Manager. Select the Performance tab to see how many cores and logical processors your PC has.

How many cores do I have command line?

You can use one of the following command to find the number of physical CPU cores including all cores on Linux: lscpu command. cat /proc/cpuinfo. top or htop command.

What is number of core per processor?

Conclusion. When buying a new computer, whether a desktop PC or laptop, it's important to know the number of cores in the processor. Most users are well served with 2 or 4 cores, but video editors, engineers, data analysts, and others in similar fields will want at least 6 cores.


1 Answers

In order to find all of the processors in a system, you must parse either the ACPI tables or Intel's MP configuration table. See Bringing SMP to your UP Operating System for a tutorial on using the MP configuration table to find and start other processors. Find more information on ACPI at http://www.acpi.info/spec.htm. You may also want to check out Detecting CPU Topology, which can tell you which processors and cores are on which physical chip within a system.

When working on your OS, http://wiki.osdev.org will be your best friend. It is full of information on all of the different parts of operating system development, including common hardware and tools.

like image 106
ughoavgfhw Avatar answered Nov 19 '22 12:11

ughoavgfhw