Lecture 03 Operating System Components
Dr. Tushar, Mosaddek Hossain Kamal
Professor
Computer Science and Engineering, University of Dhaka,
BSc Third Year, Semester 2 (July – Dec), Academic Year: 2022
CSE3201: Operating Systems
August 02, 2022
Dr. MHK Tushar (CSE, DU) CSE3201 Operating Systems August 02, 2022 1 / 36
Outline
1 Learning Outcome
2 Operating System Components
Process
Memory Management
Virtual Memory
File System
Information Protection & Security
Scheduling & Resource Management
3 Operating System Structure
Monolithic Operating System Structure
Microkernel-Based System
4 Part2: System Calls
Dr. MHK Tushar (CSE, DU) CSE3201 Operating Systems August 02, 2022 2 / 36
Learning Outcome
Understand the basic components of an Operating System
Process, Memory, File System, System Calls, Operating System
Structure, Resource management
Understand the concepts of Operating System components and
their interactions
Dr. MHK Tushar (CSE, DU) CSE3201 Operating Systems August 02, 2022 3 / 36
Operating System Components
Process
A program in execution
An instance of a program running on a computer
The entity that can be assigned to and executed on a processor
A unit of resource ownership
A unit of activity characterized by a single sequential thread of
execution, a current state, and an associated set of system
resources
Nowadays the execution abstraction is separated out: Thread
Single process can contain many threads
Dr. MHK Tushar (CSE, DU) CSE3201 Operating Systems August 02, 2022 4 / 36
Process
Consist of three segments
Text
contains the code
(instructions)
Data
Global variables
Stack
Activation records of
procedure
Local variables
Note
data can dynamically grow
up
The stack can dynamically
grow down Figure 1: Process Memory
Dr. MHK Tushar (CSE, DU) CSE3201 Operating Systems August 02, 2022 5 / 36
Process
Process Consists of three components
An executable program
Text
Associated data needed by the program
Data and stack
Execution context of the program
All information the operating system
needs to manage the process
Registers, program counter, stack
pointer, etc. . .
A multithread program has a stack and
execution context for each thread
Dr. MHK Tushar (CSE, DU) CSE3201 Operating Systems August 02, 2022 6 / 36
Multiprocess Creates Concurrency issues
Figure 2: (a) Potential Deadlock, (b) Actual Deadlock
Dr. MHK Tushar (CSE, DU) CSE3201 Operating Systems August 02, 2022 7 / 36
Memory Management
The view from thirty thousand feet
Process isolation
Prevent processes from accessing each
others data
Automatic allocation and management
Don’t want users to deal with physical
memory directly
Support for modular programming
Protection and access control
Still want controlled sharing
Long-term storage
OS services
Virtual memory
File system
Dr. MHK Tushar (CSE, DU) CSE3201 Operating Systems August 02, 2022 8 / 36
Virtual Memory
Allows programmers to address memory from a logical point of
view
Gives apps the illusion of having RAM to themselves
Logical addresses are independent of other processes
Provides isolation of processes from each other
Can overlap execution of one process while swapping in/out others.
Dr. MHK Tushar (CSE, DU) CSE3201 Operating Systems August 02, 2022 9 / 36
Virtual Memory Addressing
Figure 3: Virtual Memory Addressing
Dr. MHK Tushar (CSE, DU) CSE3201 Operating Systems August 02, 2022 10 / 36
Paging
Allows process to be comprised of a number of fixed-size blocks,
called pages
Virtual address is a page number and an offset within the page
Each page may be located any where in main memory
A page may actually exist only on disk
Dr. MHK Tushar (CSE, DU) CSE3201 Operating Systems August 02, 2022 11 / 36
Virtual Memory
Figure 4: Virtual Memory Concept
Dr. MHK Tushar (CSE, DU) CSE3201 Operating Systems August 02, 2022 12 / 36
File System
Implements long-term store
Information stored in named objects called files
Figure 5: File System Example
Dr. MHK Tushar (CSE, DU) CSE3201 Operating Systems August 02, 2022 13 / 36
Information Protection & Security
Access control
regulate user access to the system
Involves authentication
Information flow control
regulate flow of data within the system and its delivery to users
Dr. MHK Tushar (CSE, DU) CSE3201 Operating Systems August 02, 2022 14 / 36
Scheduling & Resource Management
Scheduling & Resource Management
Fairness
give equal and fair access to all processes
Differential responsiveness
discriminate between different classes of jobs
Efficiency
maximize throughput, minimize response time, and accommodate
as many uses as possible
Dr. MHK Tushar (CSE, DU) CSE3201 Operating Systems August 02, 2022 15 / 36
Operating System Structure
The layered approach
a Processor allocation and
multiprogramming
b Memory Management
c Devices
d File system
e Users
Each layer depends on the the
inner layers Figure 6
Dr. MHK Tushar (CSE, DU) CSE3201 Operating Systems August 02, 2022 16 / 36
Operating System Structure
In practice, layering is only a guide
Operating Systems have many inter-dependencies
Scheduling on virtual memory
Virtual memory on I/O to disk
VM on files (page to file)
Files on VM (memory mapped files)
And many more. . .
Dr. MHK Tushar (CSE, DU) CSE3201 Operating Systems August 02, 2022 17 / 36
The Monolithic Operating System Structure
Monolithic Kernel
Also called the “spaghetti
nest” approach
Everything is tangled up
with everything else.
Implement user services
and kernel services
separately
How use same address
space
Make operating system
faster
Switching between
user mode to kernel Figure 7: Spaghetti
mode
Linux, Windows, . . . .
Dr. MHK Tushar (CSE, DU) CSE3201 Operating Systems August 02, 2022 18 / 36
The Monolithic Operating System Structure
The Monolithic Operating System Structure
However, some reasonable structure usually prevails
Figure 8: Monolithic Kernel Structure
Dr. MHK Tushar (CSE, DU) CSE3201 Operating Systems August 02, 2022 19 / 36
Monolithic Kernel Example: UNIX
Monolithic Kernel Example: UNIX
Provides a good
hardware abstraction
Everything is a file
(mostly)
Runs on most hardware
Comes with a number
of user services and
interfaces
Shell
C compiler
Note: Unix is the OS that
creates or motivates all
modern OS (including
Mobile OS, Android, and
Linux)
Dr. MHK Tushar (CSE, DU) CSE3201 Operating Systems August 02, 2022 20 / 36
Traditional Unix Structure
Traditional Unix Structure
Dr. MHK Tushar (CSE, DU) CSE3201 Operating Systems August 02, 2022 21 / 36
Traditional Unix Structure
Traditional Unix Structure
Dr. MHK Tushar (CSE, DU) CSE3201 Operating Systems August 02, 2022 22 / 36
Microkernel-Based System
Microkernel-Based System
Assigns only a few essential functions to the kernel
Address space
Interprocess Communication (IPC)
Basic scheduling
Minimal hardware abstraction
Other services implemented by user-level servers
Traditional “system calls” become IPC requests to servers
Extreme view of a micro-kernel
A feature is only allowed in the kernel if required for security
expensive and poor in performance
Example: Minix – Andrew S. Tanenbaum and Linus Torvald – debate
(Linux kernel structure???)
L4 Micro kernel – Unix like OS – L4Ka::Hazelnut, L4/Fiasco,
L4Ka::Pistachio
Hyper-vision – Nano-Kernel
Dr. MHK Tushar (CSE, DU) CSE3201 Operating Systems August 02, 2022 23 / 36
Monolithic OS structure
Figure 9: Monolithic Kernel
Dr. MHK Tushar (CSE, DU) CSE3201 Operating Systems August 02, 2022 24 / 36
Microkernel OS structure
Figure 10: Micro-Kernel OS
Dr. MHK Tushar (CSE, DU) CSE3201 Operating Systems August 02, 2022 25 / 36
Part2: System Calls
A high-level view of System Calls
Mostly from the user’s perspective – From textbook (section 1.6)
A look at the Cortex-M4
A brief overview
Mostly focused on exception handling (Alert: URL may change)
From ‘Book in Reference’,
Data Sheet,https:
//www.st.com/resource/en/datasheet/stm32f446re.pdf
Reference Manual
https://www.st.com/resource/en/reference_manual/
dm00135183-stm32f446xx-advanced-arm-based-32-bit-mcus-stmicroelect
pdf,
Programming Manual
https://www.st.com/resource/en/programming_manual/
pm0214-stm32-cortexm4-mcus-and-mpus-programming-manual-stmicroelec
pdf
Allow me to provide “real” examples of theory
System Call implementation
Case Study: OS CSE and RTOS system call handling
Dr. MHK Tushar (CSE, DU) CSE3201 Operating Systems August 02, 2022 26 / 36
Operating System: System Calls
Figure 11: OS Syscalls
Dr. MHK Tushar (CSE, DU) CSE3201 Operating Systems August 02, 2022 27 / 36
System Calls
Operating System: System call
Can be viewed as special procedure calls
Provides for a controlled entry into the kernel
While in kernel, they perform a privileged operation
Returns to original caller with the result
The system call interface represents the abstract machine provided
by the operating system.
Dr. MHK Tushar (CSE, DU) CSE3201 Operating Systems August 02, 2022 28 / 36
A Brief Overview of classes of System Calls
From the user’s perspective
Process Management
File I/O
Directories management
Some other selected Calls
There are many more
On Linux, see man syscalls for a list
Dr. MHK Tushar (CSE, DU) CSE3201 Operating Systems August 02, 2022 29 / 36
Some System Calls For Process Management
Figure 12: Process Management Syscalls
Dr. MHK Tushar (CSE, DU) CSE3201 Operating Systems August 02, 2022 30 / 36
Some System Calls For File Management
Figure 13: File management Syscalls
Dr. MHK Tushar (CSE, DU) CSE3201 Operating Systems August 02, 2022 31 / 36
Some System Calls For Directory Management
Figure 14: Directory Syscalls
Dr. MHK Tushar (CSE, DU) CSE3201 Operating Systems August 02, 2022 32 / 36
Some System Calls For Miscellaneous Tasks
Figure 15: Misc. Syscalls
Dr. MHK Tushar (CSE, DU) CSE3201 Operating Systems August 02, 2022 33 / 36
System Calls
Figure 16: Syscalls for Shell
Dr. MHK Tushar (CSE, DU) CSE3201 Operating Systems August 02, 2022 34 / 36
System Calls
Figure 17: Unix/Win32 Syscalls
Dr. MHK Tushar (CSE, DU) CSE3201 Operating Systems August 02, 2022 35 / 36
RTOS and Bare-metal System call
Figure 18: RTOS and Bare-Metal Syscalls
Dr. MHK Tushar (CSE, DU) CSE3201 Operating Systems August 02, 2022 36 / 36
IOS Syscalls
Dr. MHK Tushar (CSE, DU) CSE3201 Operating Systems August 02, 2022 37 / 36