0

The Boot-up process of a computer starts with single thread in 0 core of the 0 processor, but after operating system kernel code is loaded and executed, the processor establish the multi-core processing(multi-thread).

How does operating system kernel enable Multi-Core execution? (What's the assembly code that did this?)

1 Answers1

1

According to the MP spec:

One processor runs at boot time, the BSP (Boot System Processor). All other CPUs, APs (Application Processors), are disabled either by hardware or the BIOS (or both). The APs have to be enabled by the OS (hence AT compatibility), via APIC IPIs (INIT & STARTUP). Before enabling, they are in a halt state with interrupts disabled (however INIT & STARTUP IPIs are not masked).

So the rest of the logical CPUs are started up by sending them Inter-Processor Interrupts, after putting some code wherever it is they will try to run code from.

It's probably more useful to think of it in terms of programming the APIC (Advanced Programmable Interrupt Controller) to deliver an interrupt to the other cores to wake them up. The ACPI tables provide the necessary information to decide exactly what to do. (Thanks to Ross Ridge for the clarification: this is done with normal store instructions into MMIO space).

This should be sufficient for a conceptual understanding of how it works, rather than to actually implement it yourself for a custom OS. As Michael Petch commented earlier, Ciro Santilli's answer on a similar question has some specific code which deals with some of the complications.

Community
  • 1
  • 1
Peter Cordes
  • 328,167
  • 45
  • 605
  • 847
  • @RossRidge: Thanks, fixed. IDK if writing down my vague high-level understanding is really helpful as an answer here, but that's all this is. :P I'm a big fan of having a high-level understanding of a wide range of things. e.g. I got https://xkcd.com/thing-explainer/ for Christmas, and really enjoyed it. :) – Peter Cordes Dec 29 '15 at 21:40
  • Thanks a lot for the answer. –  Dec 31 '15 at 01:37