Handmade Network»Forums
1 posts
How Does an OS Use Multiple Cores
Edited by Lochie on
In my research I have found that if you want to use more than one cpu core, you have to interface with the kernel. As I understand it, this is to utilize its scheduler.
However, how does the kernel interface with the cpu cores to create this abstraction?
For example, if I was writing an OS from scratch, what code would I write to utilize multiple cpu cores?
I'm confused because AFAIK there is no assembly instruction to say 'all this code is will be executed on core 1, and all this code on core 2' etc.
Mārtiņš Možeiko
2583 posts / 2 projects
How Does an OS Use Multiple Cores
Edited by Mārtiņš Možeiko on
Using multiple CPU cores is very different depending on architecture you want to use.

On x86 this is typically done through ACPI tables. These tables are provided by BIOS that informs OS how to use different parts of hardware, including multiple cores. ACPI has pretty complex specification that provides ability to run interpreter on specific bytecode. Yeah, it's crazy - to start modern OS you need to run interpreter.

Anyways, here's a good overview of what you need to do to find out how to enable running code on specific core through ACPI: https://www.codeproject.com/Artic...ide-CPU-Raw-Multicore-Programming