Operating System

Download Report

Transcript Operating System

Operating Systems High Level View
• Chapter 1,2
Who is the User?
•
•
•
•
End Users
Application Programmers
System Programmers
Administrators
End Users Want
•
•
•
•
•
•
•
Ease of use and learn
Adaptable to user’s style
Alternative ways to do things
Lots of visual cues
Free of nasty surprises
Reliable quick response
Consistency among features
Application Programmers Want
• Easy to write programs
– read keystrokes
– draw to screen
– change windows
• Consistent view of system
• Easy to use system facilities
– creating new windows
– accessing a network
• Platform portability
System Programmers Want
• Easy to
–
–
–
–
–
create correct programs
configure
debug
maintain
expand
Administrators Want
•
•
•
•
•
•
Easy to add or remove devices
Protect system and data
Easy to upgrade
Easy to manage user accounts
Good & predictable average response
Affordable
A Mouse Example
•
•
•
•
User moves mouse -> hardware interrupt
OS driver sees movement in pulse rate
OS moves cursor on screen
Application sees “mouseover” event ->
updates screen image
• User sees image change – clicks icon
Terms & Concepts
• Operating System - software that manages
resources of a computer & provides interfaces
to them.
• Device - piece of hardware connected to the
main computer hardware.
• Device controller - electronic interface which
controls devices connected to the computer.
Terms & Concepts
• Bus - conductors connecting many
hardware components in a computer.
• Device driver – a part of the OS that
interfaces to a device controller.
• Kernel - part of an OS that implements
basic functions – always running.
Terms & Concepts (cont.)
• Service - functions an OS provides to
users through programmer interfaces.
• Utility - programs not part of the
operating system kernel.
• Shell - user interface to most system
services – command interpreter.
Simplified PC Hardware
Bus
CPU
Disk
Controller
Video
Controller
Memory
Keyboard
Controller
Hard
Disk
Video
Monitor
Keyboard
One picture of an OS
Shell
(Command
Interpreter)
Utilities
Other
Programs
(Browsers,
games, word
processing)
Operating System Kernel
Devices
(disks,
keyboards)
Memory
CPU
A Personal Computer & OS
Command
(Command
Interpreter)
Utilities
Other Programs
(Browsers, games,
word processing)
Operating System Kernel
Device Drivers
BIOS
(DVD driver, video driver)
(Interface to hardware)
Devices
(Disks, keyboards)
CPU
Memory
The Process Concept and OS Process
Information
• Process – a program in execution
– Also called a job or task
• Has CPU state – registers
• Has allocated resources
Process States
•
•
•
•
•
Started
Ready
Running
Waiting (Blocked)
Terminated (Ended)
Process State Diagram
0 - Program
Loaded
New
1 - Process
Initialized
4 – Got What
it needed
Wait
Ready
2 – Gets
CPU Time
3 – Needs
something
5 - Interrupted
Run
6 - Finished
or aborted
Exit
7 - Exits
System
State Transitions
•
•
•
•
•
•
•
•
0 – OS is preparing the job to run
1 – Job is ready to run
2 – Job starts (or resumes) running
3 – Job is waiting for something
4 – Job waiting has finished
5 – Job is preempted
6 – Job ends or is aborted
7 – Job exits system
Process Information the
OS Maintains
• Process ID – a number (PID)
• Process Control Block (PCB)
–
–
–
–
–
–
Priority information
Process state
Processor (CPU) state
-> Memory access table
-> Open files table
-> Next PCB
Types of Processes
• User or Application Processes
• Systems Program Processes
• OS Processes
Processor Modes
• Privileged
–Monitor, kernel, supervisor,
ring 0 or system
• Non-privileged
–user or application
Types of OSs
• Single-user
• Multi-tasking or
multi-programming
• Time Sharing
• Network and distributed
• Real-Time
Single-user OS
•
•
•
•
•
One user
One process running
Limited memory management
File services
I/O services
Multi-tasking OS
•
•
•
•
Multiple processes running
May still be single user
All that a single task system does, +
CPU scheduling
– Context switching
Multi-user OS
• Multiple users
• Users are interactive
• Jobs
– are short
– need fewer resources
– need fast response time
Network/ Distributed OS
• Low-level services
– Connect to the network
– Send messages between systems
• Higher-level services
– Browsing
– File sharing
– Print services
Real-Time OS
• Time deadlines
• Hard deadlines
– Useless results or
catastrophe
• Soft deadlines
– Some lateness tolerated
Architectural Approaches to
Building an OS
•
•
•
•
Monolithic single-kernel
Microkernel and Layered
Object-oriented Approach
Virtual Machines
Monolithic Architecture
•
•
•
•
One dense module
RAM was expensive
Started adding features
Got bloated
– Harder to add to
– Harder to maintain
Layered Architecture
• Functions divided into Layers
• Each layer higher abstraction
• Hopefully don’t skip layers
– Faster
– Less portable
Layered Architecture
Shell
(Command
Interpreter)
Utilities
User Programs
(Browsers, games,
word processing)
API
Memory
Management
Processor
Scheduling
File
System
Device Drivers
Devices (disks,
keyboards)
CPU
Memory
Kernel
Microkernel Architecture
• One small module
• RAM getting cheaper
• Started removing features
– Moved into higher layers
– Run in user mode
– Still OS functions
Microkernel Architecture
Shell
(Command Interpreter)
Memory
Management
Other Programs
(Browsers, games, word
processing, …)
Utilities
Processor
Scheduling
File System
USER Mode
Microkernel
Devices (disks, keyboards, …)
KERNEL Mode
Implementation Techniques
• Interrupt Handling
– Interrupt Vectors
•
•
•
•
•
System Calls
Queues and Tables
Object Oriented Approach
Minimalist vs. Maximalist Approaches
Backward Compatibility
Interrupt Handling –
Interrupt Vectors
• Hardware signals an event
– I/O completion or fault
• Interrupt register holds interrupt #
• # used to select routine address
– Vector table in low RAM
Interrupt Vector
Interrupt Vector
Interrupt Register
Index into
interrupt vector
Address of interrupt
service routine 1
Address of interrupt
service routine 2
Address of interrupt
service routine 3
ooo
Illustrating an for handling interrupts
Address of interrupt
service routine N
System Calls
• Load registers/ variables with arguments
• TRAP instruction
• Generates an interrupt
• Automatic switch to kernel mode
• Arguments tell OS what to do
• Afterwards
• “return” as from a function call
• Force return to user mode
System Call
There are 11 steps in making the system call
4/3/2016
read (fd, buffer,
nbytes)
B.Ramamurthy
37
Some System Calls For Process Management
and File Management
4/3/2016
B.Ramamurthy
38
OS Queues and Tables
• Tables
– PCB
– Open File Table
– Page Tables
• Queues
– Ready processes
– I/O requests
– event waits
Object Oriented Architecture
•
•
•
•
A collection of objects
Better software engineering
Performance penalty
Any object can use any other
Virtual Machine Architecture
•
•
•
•
OS emulates hardware architecture
Runs other OS, not user applications
Good for OS development
Related – simulate abstract machines
– Java
– .Net CLR
Hardware Virtual Machine Model
Shell, Utilities, or
Shell, Utilities, or
Shell, Utilities,
Programs
Programs
or Programs
Kernel 1
Kernel 2
Kernel 3
Virtual Machine
Devices (disks, keyboards, … ), CPU, Memory
Minimalist vs. Maximalist
• Less is more
–
–
–
–
Minimum in kernel
Else in libraries and layers
More choices
Linux
• All in One
– Operating Standards
– MAC OS