0
$\begingroup$

Im trying to figure out if there's an assembler instructions or a bios intruction to get multi-threading in a kernel. In the case that doesn't exist that, how could i set muti-threading in a kernel?

$\endgroup$

2 Answers 2

1
$\begingroup$

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 "core 0" 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.

$\endgroup$
0
$\begingroup$

That is a overall kernel design issue, not a single assembler instruction. BIOS is an (obsolete) piece of startup machinery for PCs, it had very little incidence on full-fledged kernels (after initializing stuff and stashing away some data for later use befor handing control to the kernel, that is). Such a kernel will have to use synchronization techniques to make sure no part of the code tramples on the work of another thread.

With today's multi-core chips, any non-toy kernel is forced to be multithreaded (running on just one core and making sure no other core can interfere is just too inefficient).

$\endgroup$

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge that you have read and understand our privacy policy and code of conduct.

Not the answer you're looking for? Browse other questions tagged or ask your own question.