How to use multiple cores? #1398
-
How to utilize multiple cores to run tasks at the same time instead of collaborative multitasking or sharing CPU time? |
Beta Was this translation helpful? Give feedback.
Replies: 1 comment 3 replies
-
You want SMP I assume. I'm new to this so I'm trying to summarize what I understood (keep in mind I have a working SMP setup right now, so there has to be some truth in what I'm about to say). The bootloader initializes all available cores and puts all except one to sleep. That one core (CPU from now on) is your bootstrap CPU (BSP). Once your kernel is loaded (and the mapping is set up etc.), the bootloader (running on the BSP) jumps to your kernel. Your kernel (running on the BSP) now needs to somehow start the APs (the other, currently sleeping, non BSP CPUs). This may be an entry point for you into more research. I currently don't do what those pages describe for initialization (with IPIs etc). I use limine as bootloader, and limine provides a really convenient way of making another core execute code (it basically lets me just call a function with a function pointer and that will be executed on another core). Once you get your APs up and running, keep in mind that GDT, IDT and Cr3 are CPU specific, meaning you need to set them up for each core. You can reuse a memory mapping from another core, but you have to find a way to pass them to the core. Depending on the bootloader, those may be initialized or not (limine conveniently does set them up just like the BSP). You can use the |
Beta Was this translation helpful? Give feedback.
You want SMP I assume. I'm new to this so I'm trying to summarize what I understood (keep in mind I have a working SMP setup right now, so there has to be some truth in what I'm about to say).
The bootloader initializes all available cores and puts all except one to sleep. That one core (CPU from now on) is your bootstrap CPU (BSP). Once your kernel is loaded (and the mapping is set up etc.), the bootloader (running on the BSP) jumps to your kernel.
Your kernel (running on the BSP) now needs to somehow start the APs (the other, currently sleeping, non BSP CPUs).
This may be an entry point for you into m…