OS-LecturePPT Unit 1 AY2021-22 TechngVrsn
OS-LecturePPT Unit 1 AY2021-22 TechngVrsn
References:
1) https://www.cse.iitb.ac.in/~mythili/os/
2) nptel.ac.in/courses/106106144/
3) https://nptel.ac.in/courses/106108101
Unit 1
CO1:
Acquire basic knowledge about different functions,
structures and design features of contemporary operating
systems, to aid in applying and solving complex
engineering problems.
What is an Operating System?
A program that acts as an intermediary between
user Programs and the computer hardware
OS is a resource allocator
• Manages all resources: CPU, memory, and
I/O devices (disk, network card, mouse, keyboard etc.)
• Decides between conflicting requests for efficient and
fair resource use
OS is a control program
•Controls execution of programs, to prevent errors and
improper use of the computer
Operating system goals:
• To provide Usable Computing Environment: The
fundamental goal of Computer System is to
execute user programs and make solving user
problems easier.
• Convenience, Abstraction of hardware
resources for user programs
• Efficient use of computer hardware
Why bother with an OS?
• Application benefits
• programming simplicity
• see high-level abstractions (files) instead of low-level
hardware details (device registers)
• abstractions are reusable across many programs
• portability (across machine configurations or architectures)
• device independence: 3com card or Intel card?
• User benefits
• safety
• program “sees” its own virtual machine, thinks it “owns”
the computer
• OS protects programs from each other
• OS fairly multiplexes resources across programs
• efficiency (cost and speed)
• share one computer across many users
• concurrent execution of multiple programs
© 2012 Gribble, Lazowska, Levy, Zahorjan
5
Computer System Structure
• Computer system can be divided into four components:
• Hardware – provides basic computing resources
• CPU, memory, I/O devices
• Operating system
• Controls and coordinates use of hardware among
various user application programs
• Application programs – solve the computing problems
of the users
• Word processors, compilers, web browsers,
database systems, video games
• Users
• People, machines, other computers
Abstract View of Components of Computer
Virtual Machine Abstraction
Application
Hardware
1) User Interface
Command-Line (CLI), Graphical user interface (GUI)
2) Program execution (Process execution)
•Creating and deleting both user and system processes
•Suspending and resuming processes
•Providing mechanisms for process synchronization
•Providing mechanisms for process communication
3) I/O operations - A running program may require
I/O, which may involve a file or an I/O device
- desktop PC’s
- handheld devices (PDAs, smart phones
Media Delivery
- Communications
• create, delete communication connection
• send, receive messages
• transfer status information
• attach and detach remote devices
- Protection
• Control access to resources
• Get and set permissions
• Allow and deny user access
Examples of Windows and Unix System Calls
System Programs
• Provide a convenient environment for program
development and execution
• File management - Create, delete, copy, rename,
print, dump, list, and generally manipulate files and
directories
• Status information
• Some ask the system for info - date, time, amount
of available memory, disk space, number of users
• Provide detailed performance, logging, and
debugging information
• Some systems support, a registry – which is used
to store and retrieve configuration information
• File modification
• Text editors to create and modify files
• Programming-language support - Compilers,
assemblers, debuggers and interpreters
• Program loading and execution- Absolute loaders,
relocatable loaders, and overlay-loaders
• Communications - Provide the mechanism for
creating virtual connections among processes,
users, and computer systems
• Allow users to send messages to one another’s
screens, browse web pages, send electronic-mail
messages, log in remotely, transfer files from one
machine to another
Operating System Design and Implementation
• Layered structure
• Modular structure
1. Simple Structure -- MS-DOS
Characteristics:
•OS is divided into layers
•The bottom layer (layer 0), is the
hardware; the highest (layer N) is
the user interface.
• With modularity, layers are
selected such that each uses
functions (operations) and services
of only lower-level layers
•Layer M can be invoked by layer
M+1
•Layer M can invoke layer M-1
Advantages:
-Testing & debugging is easy
-Design and implementation are simplified
Difficulties (Disadvantages):
-Designing layers and identifying objects in those layers
Step 2): Load saved state from the scheduled process PCB
The above two steps constitute context switching
• Otherwise, it is preemptive.
• Maximise throughput
P1 P2 P3
0 24 27 30
P2 P3 P1
0 3 6 30
P4 P1 P3 P2
0 3 9 16 24
• Commonly, α set to ½
Prediction of the Length of the Next CPU Burst
Examples of Exponential Averaging
• =0
• n+1 = n
• Recent history does not count
• =1
• n+1 = tn
• Only the actual last CPU burst counts
• If we expand the formula, we get:
n+1 = tn+(1 - ) tn -1 + …
+(1 - )j tn -j + …
+(1 - )n +1 0
P1 P2 P4 P1 P3
0 1 5 10 17 26
P1 P2 P3 P1 P1 P1 P1 P1
0 4 7 10 14 18 22 26 30
• Scheduling
• A new job enters queue Q0 which is
served FCFS
• When it gains CPU, job receives 8
milliseconds
• If it does not finish in 8
milliseconds, job is moved to
queue Q1
• At Q1 job is again served FCFS and
receives 16 additional milliseconds
• If it still does not complete, it is
preempted and moved to queue
Q2
Threads
• Many-to-One
• One-to-One
• Many-to-Many
Many-to-One
• Many user-level threads mapped to single kernel thread
• Examples:
• Examples
• Windows
• Linux
Many-to-Many Model
• Allows many user level threads to be mapped to many
kernel threads
• Allows the operating system to create a sufficient number of
kernel threads
• Linux scheduling
• Windows scheduling
Linux Scheduling
• REALTIME_PRIORITY_CLASS,
• HIGH_PRIORITY_CLASS,
• ABOVE_NORMAL_PRIORITY_CLASS,
• NORMAL,
• BELOW_NORMAL_PRIORITY_CLASS,
• IDLE_PRIORITY_CLASS