Kernel
- The kernel is responsible for maintaining all the important abstractions of the operating system, including such things as virtual memory and processes.
- The Linux kernel forms the core of the Linux operating system. It provides all the functionality necessary to run processes, and it provides system services to give arbitrated and protected access to hardware resources.
- The kernel implements all the features required to qualify as an operating system on its own. However, the Linux kernel looks nothing like a UNIX system; it is missing many of the extra features of UNIX.
- The operating-system interface visible to running applications is not maintained directly by the kernel Rather; applications make calls to the system libraries, which in turn call the operating system services as necessary.
Memory Management:
Memory management under Linux has two components.
- The first deals with allocating and freeing physical memory-pages, groups of pages, and small blocks of memory.
- The second handles virtual memory, which is memory mapped into the address space of running processes
Management of Physical Memory:
Due to specific hardware characteristics, Linux separates physical memory into three different zones: ZONE_DMA, ZONE_NORMAL, ZONE_HIGHMEM
Zone |
Physical Memory |
ZONE_DMA |
$<$ 16 MB |
ZONE_NORMAL |
16 ... 896 MB |
ZONE_HIGHMEM |
$>$896 MB |
The primary physical-memory manager in the Linux kernel is the page allocator. Each zone has its own allocator, which is responsible for allocating and freeing all physical pages for the zone and is capable of allocating ranges of physically contiguous pages on request.
The allocator uses a buddy system to keep track of available physical pages. In this scheme, adjacent units of allocatable memory are paired together. Each allocatable memory region has an adjacent partner (or buddy). Whenever two allocated partner regions are freed up, they are combined to form a larger region-a buddy heap
Fig. Splitting of memory in the buddy system
Scheduling
- The Linux kernel ran a variation of the traditional UNIX scheduling algorithm. Two problems with the traditional UNIX scheduler are:
- It does not provide adequate support for SMP systems
- It does not scale well as the number of tasks on the system grows.
- The scheduler was overhauled, and the kernel now provides a scheduling algorithm that runs in constant time.
- The Linux scheduler is a preemptive, priority-based algorithm with two separate priority ranges: a real-time range from 0 to 99 and a nice value ranging from 100 to 140. These two ranges map into a global priority scheme wherein numerically lower values indicate higher priorities.
- Unlike schedulers for many other systems like windows, Linux assigns higher-priority tasks longer time quanta and lower-priority tasks shorter time quanta. The relationship between priorities and time-slice length is shown in Figure below.
Fig. The relationship between priorities and time-slice length