Chapter 1:
Introductio
n to
Operating
Systems
Smruti R Sarangi
IIT Delhi
(c) Smruti R. Sarangi, 2023 1
What is an Operating Systems (OS)?
It is a special program
Can control other programs
Exercises control over hardware
(c) Smruti R. Sarangi, 2023 2
Background Required for the Course
C/C++ programming proficiency
Computer Architecture
Data Structures
(c) Smruti R. Sarangi, 2023 3
Key Components Who manages these?
CPU
Memory Hard
Disk
I/0 devices
4
(c) Smruti R. Sarangi, 2023
Place of the 0S
Programs
P1 P2 P3 Between
application
software and
hardware
Operating System
CPUs
Hardware
Memory
(c) Smruti R. Sarangi, 2023
I/O & Storage
5
Why do we need a special program,
the 0S?
• Many programs share common hardware (HW)
• The access to common hardware needs to be regulated
• Hardware: CPU, memory, I/0 and storage
• Schedule the CPU
• Interface with devices
• Manage storage
• Manage memory
Power, temperature
• Security
and security concerns
• Make it easy to build distributed systems
• Makes it easy to work with HW
(c) Smruti R. Sarangi, 2023 6
Basic Idea: Arbitration and Regulating
Accesses
• A process is an instance of a running program Arbitration
• At any point of time multiple processes are active
• The processes have different requirements
• The 0S arbitrates between the processes
• Accessing HW is very complex
Access
• Elaborate protocols
• Same code needs to run on multiple machines
• Provide a common interface: device derivers in the 0S
7
(c) Smruti R. Sarangi, 2023
Space of operating Systems
HPC and server
Desktop/laptop
Mobile
Even wearables
(c) Smruti R. Sarangi, 2023 8
History of Linux : Milestones
1991 Linus Torvalds started extending the MINIX 0S
1992 Released under the GPL license. Available on the web.
2000 – 2010 Takes over the server and HPC market
Android (Linux-based) becomes the most popular mobile
2012 – 2020 Operating System
(c) Smruti R. Sarangi, 2023 9
Why teach a real world 0S?
• Conveys a realistic picture
• Provides real-world skills
We will learn generic concepts in the context of Linux
(c) Smruti R. Sarangi, 2023 10
Open Source Design
Freely available source code
www.kernel.org
https://elixir.bootlin.com/linux/v6.2.12/source/kernel
Version 6.2.12
(c) Smruti R. Sarangi, 2023 11
Bane and Boon of the GPL License
• Freedom to use, modify and distribute • Quite restrictive in nature
• All derivative works are also under GPL • Need to disclose all modifications
• Fosters collaboration • Cannot build appliances (HW+SW)
• Prohibits tivoization: cannot restrict combos that involve kernel modifications
hardware to a given piece of GPL-protected
software that is protected with a key
(c) Smruti R. Sarangi, 2023 12
Some Kernel Source Code Statistics
• Roughly 25 million lines of source code
• Per version, 250k lines of code change Current version: 6.2.12
x y z -rc<num>
rc release candidate
(test release)
Major version
number Patch number
Minor version
number
(c) Smruti R. Sarangi, 2023 13
Details of the Linux Code Base
Most of the code
is drivers
(c) Smruti R. Sarangi, 2023 14
Major Subsystems in Linux
(Directory-wise)
init: boot code
All the code
Process manager
HW-dependent code
Memory
and I/O
kernel: process scheduler,
synchronization, time mm: physical and virtual arch: All the assembly code
management, event memory manager that is architecture
management, debugging dependent
fs: file systems
virt: Support for running a drivers: All the kernel
block: generic layer for
guest OS as a regular routines that run the
all block-based storage
program. devices. Translate generic
devices like hard disks
io_uring: data structures OS calls to HW-specific
for I/O support
(c) Smruti R. Sarangi, 2023 instructions. 15
The arch Folder
• The Linux codebase has two parts: machine dependent and machine
independent
• Most of the code is machine independent. Otherwise, it will become
impossible to manage such a large codebase.
• We need a layer to abstract out details of the underlying machine.
• This is the job of the arch folder (machine dependent part) that:
• The kernel uses generic data types such as u32 or u64. They are defined
within files of the arch folder (for each architecture)
• Map high-level primitives to assembly-level code snippets (arch. specific)
• Provide other low-level services: booting the system, managing the memory
system, power management, etc.
(c) Smruti R. Sarangi, 2023 16
Factoid
Android, Chrome OS, Tizen (Samsung),
Web OS (LG) are all based on Linux.
(c) Smruti R. Sarangi, 2023 17
(c) Smruti R. Sarangi, 2023 18
Fundamentals: cores, Processes,
registers, interrupts, synchronization,
virtual memory, I/O scheduling
OS
Communication: Memory system,
interrupts, system calls virtualization,
+ I/O system and security
device drivers
(c) Smruti R. Sarangi, 2023 19
[email protected]n
(c) Smruti R. Sarangi, 2023 20