How could i create a multi-threading system in a kernel?
In a multiprocessing system the other cores of the CPU are initiated with boot code like UEFI or legacy bootloader just like the first core of the computer.
The CPU is manufactured to use a &quot;core 0&quot; as the first core of the system. After boot, the kernel needs to use the Local APIC of core 0 to send IPI ( interprocessor interrupts) to other cores to start them. As stated on osdev.org,
IPIs are sent through the BSP's LAPIC. Find the LAPIC base address from the MP tables or ACPI tables, then you can write 32-bit words to base + 0x300 and base + 0x310 to send IPIs. For a init IPI or startup IPI, you must first write the target LAPIC ID into bits 24-27 of base + 0x310. Then, for an init IPI, write 0x00004500 to base + 0x300. For a SIPI, write 0x00004600, ored with the page number at which you want to AP to start executing, to base + 0x300. For more information, see http://wiki.osdev.org/APIC#Local_APIC_registers.