OS - C1 - Introduction To OS
OS - C1 - Introduction To OS
Introduction to
Operating System
Lecturer: VU THI MY HANG
OPERATING SYSTEM
Plan
OPERATING SYSTEM 2
Plan
OPERATING SYSTEM 3
WHAT and WHY an Operating System?
A system program
• Provides an easy way to execute application programs, i.e.,
user programs solving user problems (e.g., word processor,
web browser)
• Acts as an interface between application programs and
computer hardware (e.g., CPU, memory, I/O devices)
OPERATING SYSTEM 4
WHAT and WHY an Operating System?
operating system
computer hardware
OPERATING SYSTEM 5
WHAT and WHY an Operating System?
OPERATING SYSTEM 6
WHAT and WHY an Operating System?
OPERATING SYSTEM 7
WHAT and WHY an Operating System?
Read file
“abc.txt”
working with
working with files track, sector, etc.
OS
OPERATING SYSTEM 8
Plan
OPERATING SYSTEM 9
System Calls
OPERATING SYSTEM 10
System Calls
KERNEL
Kernel
mode Device controllers
C program calls “printf” function, which Windows and Unix System Calls
invokes “write” system call
OPERATING SYSTEM 12
Plan
OPERATING SYSTEM 13
Classification
Batch OS
• A job/program (i.e., set of instructions, data)
ü Stored on punched cards, which are read by card readers
• A batch (i.e., set of similar jobs)
ü Executed one by one without user interaction directly
L CPU is idle while the current job is waiting for I/O to complete
L Lack of user interaction
Batch 1 Batch 2
Job1 Job3
Job2 Job4
Multiprogramming OS
• Multiple programs are kept in memory simultaneously
• While the current program is waiting for an I/O operation,
the CPU switches to another
J Maximize CPU utilization
L CPU scheduling?
OS
L Memory protection?
P1 Memory
partitions
P2
…
OPERATING SYSTEM 15
Classification
Multiprogramming OS
Batch system vs. Multiprogramming system
Batch
CPU P1 Idle P1 P2 Idle P2
I/O P1 P2
Multiprogramming
CPU P1 P2 P1 P2
I/O P1 P2
OPERATING SYSTEM 16
Classification
OPERATING SYSTEM 17
Classification
OPERATING SYSTEM 18
Classification
Real-time OS (RTOS)
• Tasks must complete within time constraint
• Hard real-time system: time constraint must be respected
ü Time delay causes system failure (i.e., tasks MUST be done on time or fail)
ü E.g., industrial control systems, traffic control system
• Soft real-time system
• Time delay accepted occasionally
• E.g., multimedia system
L Limited – Complex - Expensive
OPERATING SYSTEM 19
Classification
Distributed OS
• Consists of independent systems linked via network
• Need for a distributed OS
ü Resource sharing
ü Job collaboration
ü Computing power increase
OPERATING SYSTEM 20
Classification
Embedded OS
• Installed on phones, PDAs, and other devices (not a computer)
• Designed for specific purpose
• May or may not have user interface
L Limited resources (low CPU, small memory, no disk, ...)
L Complex algorithm
OPERATING SYSTEM 22
Main components
OPERATING SYSTEM 23
Main components
Memory Management
• In a multiprogramming system, many programs to be executed
(i.e., process) are resident in memory simultaneously.
• OS deals with:
ü Memory allocation, deallocation, and protection (against invalid access)
ü Virtual memory management
o To have more space ...
o Programs loaded into memory partially ...
OPERATING SYSTEM 24
Main components
File Management
• A file is an abstract concept provided by OS to store collection of
data on disk
• OS deals with:
ü File organization
ü File allocation/deallocation
ü File storage on disk
OPERATING SYSTEM 25
Main components
I/O Management
• OS acts as an intermediary between I/O request and physical
devices (e.g., mouse, keyboard, screen, printer)
• OS deals with:
ü I/O hardware communication (e.g., device controller, DMA, polling,
interrupt I/O)
ü I/O software, which allows accessing and managing I/O operations (e.g.,
device driver, interrupt handler)
OPERATING SYSTEM 26
Main components
ing
ar n
lf-le
Se
OPERATING SYSTEM 27
Plan
OPERATING SYSTEM 28
OS structure
Simple structure
• OS components are not well separated (e.g., MS-DOS)
• Application programs can access computer hardware directly
J Simple and easy to extend
L Vulnerable
ü What if an application program fails?
OPERATING SYSTEM 29
OS structure
Monolithic structure
• OS components are combined into one single module (e.g.,
traditional UNIX systems)
• Each procedure (function) can call any other procedures
J Simple and fast
L Difficult to implement and maintain
User
Kernel
OPERATING SYSTEM 30
OS structure
Layered structure
• OS components are structured into layers (e.g., MULTICS)
• Each layer uses services (operations, functions) prepared by its
lower adjacent layer
ü layer N calls services defined in layer N-1
J Easier to implement and maintain than monolithic structure
L How to group services into layers? based on
functionality?
L When invoking a system call, a user program
may need to pass through many layers
à efficiency?
OPERATING SYSTEM 31
OS structure
Microkernel structure
• Kernel only stores essential components of OS (e.g., Mach)
• Other components are implemented as user programs
J Easy to manage, extend and build new architecture
J Security and Reliability Application File Device user
Program System Driver User
mode
Interprocess memory
managment
CPU
scheduling
Kernel
kernel
Communication mode
microkernel
hardware
OPERATING SYSTEM 32
OS structure
Module structure
• A system consists of core kernel and additional services
implemented as modules linked dynamically (e.g., Solaris)
J Easier to add new service than modify the kernel
J Security
L Not a clear design
OPERATING SYSTEM 33
OS structure
Hybrid structure
• A combination of various structures to address performance,
security and usability
• Common design in many modern OS (e.g., Linux, Mac OS X,
Windows, Android)
OPERATING SYSTEM 36
Topic 1