Case Study of Linux - Linux Kernel Version 2.6
Case Study of Linux - Linux Kernel Version 2.6
6
Core of the most popular open-source, freely distributed, fullfeatured operating system Linux source code is available to the public for examination and modification and is free to download and install
Popular in high-end servers, desktop computers and embedded systems Supports many advanced features
Symmetric multiprocessing (SMP), Access to multiple file systems Support for broad spectrum of hardware architectures
History Created in 1991 by Linus Torvalds a student at the University of Helsinki, Finland
The name Linux is derived from Linus and UNIX
The Minix source code served as a starting point Torvalds sought advice from the community Developers continued to support the concept of a new, freely available operating system
History Distribution
Enables users unfamiliar with Linux details to install and use Linux Includes software such as
The Linux kernel System applications (e.g., user account management, network management and security tools) User applications (e.g., GUIs, Web browsers, text editors, e-mail applications, databases, and games) Tools to simplify the installation process
Linux Overview Linux systems include user interfaces and applications in addition to the kernel Borrows from the UNIX layered system approach System contains kernel threads to perform services
Implemented as daemons, which sleep until awakened by a kernel component
Multiuser system
Restricts access to important operations to users with superuser (also called root) privileges
Development and Community Torvalds controls all modifications to the kernel Relies on a group of about 20 lieutenants to manage kernel enhancements As a development kernel nears completion:
Feature freeze: no new features are added to the kernel Code freeze: only code that fixes important bugs are accepted
Many corporations support Linux development Linux is distributed under the GNU Public License (GPL) Linux is free, copyrighted software
Distributions Over 300 distributions available Typically organized into packages, each containing a single service or application Popular distributions include:
Debian Mandrake Red Hat SuSE Slackware
User Interface Can be accessed via the command-line via shells such as bash, csh and esh Most Linux GUIs are layered
X Window System
Lowest level Provides to higher GUI layers mechanisms to create and manipulate graphical components
Window manager
Builds on mechanisms in the X Window System interface to control the placement, appearance, size and other window attributes
Kernel Architecture
Linux architecture.
Task states:
Running Sleeping Zombie Dead Stopped Active and expired (not stored by state)
Process Scheduling
Preemptive scheduler
Each task runs until its quantum, or time slice, expires, a higher priority process becomes runnable or the process blocks Tasks placed in run queues (similar to multilevel feedback queues) Priority array maintains pointer to each level of the run queue
Task of priority i is placed in the ith entry of the priority array for a run queue
Scheduler dispatches the task at the front of the list in the highest level of the priority array
If more than one task exists in a level of the priority array, tasks are dispatched from the priority array round-robin
Process Scheduling
Scheduler priority array.
Linux uses demand-paged system Linux uses Buddy Algorithm for Memory Allocation.
Buddy Algorithm Buddy Algorithm is a memory management algorithm used to speed up the combining of adjacent holes when a process is terminated. In buddy say allocation, is always in terms of 2n. Consider a memory size of 1MB(1024 KB). Now process A request for 70K then 128 K is allocated to the process because this is the smallest power of 2k which is greater than 70K. The memory is split as follows:
128K Process A Allocates (70K) 128K 256K 512K
Page Replacement(LFU)
LFU assumes that the page which is used less number of times in the past may not be used in the near future and hence marks that page for replacement. The O.S. must maintain a counter for each page present in the core. This counter is updated every time the page is used. When the page fault occurs the page with smallest counter is deleted. The idea is that if a page is not heavily used so far, then we assume that it behaves in the same fashion even in the future also and hence delete that page.
Ex: Let us assume that pages of a program are used in the following fashion:
7 7 7 0 1 1 2 0 0 3 0 0 3 3 4 Let us assume that there are 3 frames in the memory
7 7 0 7 0 1 7 1 2 7 1 0 7 0 3 7 0 4
1 Page fault = 7
Input/Output Management
Kernel provides common interface for I/O system calls Devices are grouped into classes
Members of each device class perform similar functions Allows the kernel to address the performance needs of certain devices (or classes of devices) individually
Device driver: software interface between system calls and a hardware device
Most have been written by independent developers Typically implemented as loadable kernel modules
Device Drivers
/proc/devices file contents.
Deadline scheduler
Eliminates read request starvation by ensuring all read operations are performed by a certain deadline