Multithreaded Kernel

From OSDev Wiki
Jump to navigation Jump to search

A multithreaded kernel is an operating system kernel that manages multiple threads, where each thread typically represents a function or application with its own stack and saved registers. When switching between threads, the kernel saves the current thread's state (i.e., registers and stack) and then loads the new thread's state, including the new stack, registers, and the Instruction Pointer, allowing the new thread to resume execution where it left off.

This page is under construction! This page or section is a work in progress and may thus be incomplete. Its content may be changed in the near future.

Types of multithreaded kernel

There are different types of multithreaded kernels, each relying on the specific design of the system's scheduler and how it handles task switching.

Cooperative Kernel

This is the type of app execution on macOS System Software 1.x to 9.x, and on Windows 1.0 through 3.1/3.11. Windows 95 through ME used cooperative multitasking for 16-bit apps, but preemptive multitasking for 32-bit ones.

Cooperative multitasking works via giving an app full control over a CPU core, and when it is ready to give control to the next thread, which on single core systems (most computers before 2000) is the full CPU which means any app could on accident not yield control, or do it on purpose as a form of ransomware/malware.

Preemptive Multitasking

This is the type of app execution on modern operating systems such as macOS 10.0 and later, Windows NT-based systems (32bit), and all versions of Linux.

These systems switch between threads after a set amount of time, for example every 10 milliseconds. Lets say the PIT is used, every 10 ticks (if configured to tick every millisecond) then switch to the next thread, this would be a very simple implementation of cooperative multitasking.