pptx - Operating System

advertisement
Operating Systems
Introduction to Operating System
(OS)
What is an Operating System?
• An Operating System is a program that acts as an
interface between a user of a computer and the
computer hardware.
• The purpose of an operating system is to provide
an environment in which a user can execute
programs.
• The primary goal of an operating system is thus to
make the computer system convenient to use.
• A secondary goal is to use the computer
hardware in an efficient manner.
Why Study Operating Systems?
• Abstraction — how do you give the users the illusion of
infinite resources (CPU time, memory, file space)?
• System design —tradeoffs between:
– performance and convenience of these abstractions
– performance and simplicity of OS
– functionality in hardware or software
• Primary intersection point — OS is the point where
hardware, software, programming languages, data
structures, and algorithms all come together
• “Operating systems are among the most complex
pieces of software yet developed”, William Stallings,
1994
Levels in a computer system
User
5
Abstract View of Computer System
Components
Where does the OS fit in?
Dynamic View of System Components
User and System View of OS
• User perspective : ease of usage is the main
consideration.
• System perspective : efficiency in usage of
resources is the main consideration.
As a provider of resources - OS must have a
policy and a control program to regulate the
allocation of resources
Two key OS functions
• Abstract Machine
– Hides complex details of the underlying hardware
– Provides common API to applications and services
– Simplifies application writing
• Resource Manager
– Controls (scheduling, multiplexing, transforming etc.) accesses to
shared resources
• CPU, memory, disks, network, ...
– Allows for global policies to be implemented
– Better utilization of computer hardware
10
Operating System Definitions
• Resource allocator – manages and allocates resources
• Control program – controls the execution of user programs
and operations of I/O devices
• Kernel – lies between software and hardware. The one
program running at all times (all else being application
programs)
Providing abstraction via system calls
Application
System Calls: read(), open(), write(), mkdir(), kill() ...
Operating
System
Device
Mgmt
Protection
File System
CPU
Network
Comm.
Process
Mgmt
Memory
Network
Video Card
Monitor
Disk
Security
Printer
12
O.S. Components
•
•
•
•
•
•
•
•
Process management
Main memory management
File management
I/O system management
Secondary storage management
Networking
Protection system
Command interpreter system
Process Management
• A process is a program in execution.
•
Needs (CPU time, memory, files, and I/O devices).
• Tasks of Process Management of an OS
– Create, load, execute, suspend, resume, and terminate
processes
– Process scheduling :Switch system among multiple processes in
main memory
– Provides communication mechanisms so that processes can
send (or receive) data to (or from) each other.
– Process synchronization Control concurrent access to shared
data to keep shared data consistent.
– Allocate/de-allocate resources properly to prevent or avoid
deadlock situation
Main-Memory Management
• Processes must be loaded into main memory
to be executed.
• Tasks of Main Memory Management of OS
– Keep track of which memory area is used by whom.
– Decide which processes to load when memory space becomes available.
– Allocate and de-allocate memory space as needed.
File Management
• A file is a collection of related information
defined by its creator.
Commonly, files
represent programs (both source and object
forms) and data.
• Tasks of File Management
–
–
–
–
–
File creation and deletion.
Directory creation and deletion.
Support of primitives for manipulating files and directories.
Mapping files onto secondary storage.
File backup on stable (nonvolatile) storage media.
I/O System Management
• The I/O system consists of:
– A buffer-caching system
– A general device-driver interface
– Drivers for specific hardware devices
Secondary-Storage Management
• Almost everything is stored in the secondary
storage. Therefore, secondary storage
accesses must be efficient and convenient
• Tasks of Storage Management
– Free space management
– Storage allocation
– Disk scheduling
Networking (Distributed Systems)
• A distributed system is a collection of processors
that do not share memory or a clock. Each
processor has its own local memory.
• The processors in the system are connected
through a communication network.
• Communication takes place using a protocol.
• Access to a shared resource allows:
– Computation speed-up
– Increased data availability
– Enhanced reliability
Protection System
• Protection refers to a mechanism for
controlling access by programs, processes, or
users to both system and user resources.
• The protection mechanism must:
– distinguish between authorized and unauthorized usage.
– specify the controls to be imposed.
– provide a means of enforcement.
Command-Interpreter System
• Many commands are given to the operating
system by control statements which deal with:
–
–
–
–
–
–
–
process creation and management
I/O handling
secondary-storage management
main-memory management
file-system access
protection
Networking
• The program that reads and interprets control
statements is called variously:
– command-line interpreter
– shell (in UNIX)
System Calls
• Process control
– end/abort this program
– load/execute another program
– create/terminate a process
• get/set attributes
• wait specified time
• wait for event, signal event
• File manipulation
– create/open/read/write/close/delete file
– get/set attributes
• Device manipulation
– request/read/write/release device
• Information
– get/set time/date
Evolution of Operating Systems
•
•
•
•
•
•
•
•
Early Systems (1950)
Simple Batch Systems (1960)
Multiprogrammed Batch Systems (1970)
Time-Sharing and Real-Time Systems (1970)
Personal/Desktop Computers (1980)
Multiprocessor Systems (1980)
Networked/Distributed Systems (1980)
Web-based Systems (1990)
Example of an early computer system
Simple Batch System
The user submit the job on cards or
tapes to a program operator, who
batches the jobs together
sequentially and places the entire
batch on an input device, for use by
the monitor (program)
Operation of Simple Batch Systems
• The user submits a job (written on cards or
tape) to a computer operator.
• The computer operator place a batch of several
jobs on an input device.
• A special program, the monitor, manages the
execution of each program in the batch.
Idea of Simple Batch Systems
• Reduce setup time by batching similar jobs.
• Use Automatic Job Sequencing – automatically
transfer control from one job when it finishes
to another one.
Spooling (1)
• Problem:
– Card reader, Line printer and Tape drives slow
(compared to Disk).
– I/O and CPU could not overlap.
• Solution: Spooling – Overlap I/O of one job with the computation of
another job (using double buffering, DMA, etc).
– Technique is called SPOOLing: Simultaneous
Peripheral Operation On Line.
We assumed Uniprogramming until now
• I/O operations are exceedingly slow (compared
to instruction execution).
• A program containing even a very small
number of I/O operations, will spend most of
its time waiting for them.
• Hence: poor CPU usage when only one
program is present in memory.
A. Frank - P. Weisberg
Memory Layout for Uniprogramming
Memory Layout for Batch Multiprogramming
Several jobs are kept in main memory at the same
time, and the CPU is multiplexed among them.
Multiprogramming (2)
A. Frank - P. Weisberg
Why Multiprogramming?
• Advantages
– Increases CPU utilization by organizing jobs so
that the CPU always has one to execute.
– User feels that many programs are allotted CPU
almost simultaneously.
• Disadvantages
– CPU scheduling is required.
– To accommodate many jobs in memory, memory
management is required
Time-Sharing System
• Multiprogramming does not support
interaction with users.
• Time-sharing extends Multiprogramming to
handle multiple interactive jobs –
it’s Interactive Multiprogramming.
• Multiple users simultaneously access the
system through commands entered at
terminals.
• Processor’s time is shared among multiple
users.
Batch Multiprogramming
vs. Time Sharing
Real-Time Systems
• Real-Time (RT) systems are dedicated systems
that need to adhere to deadlines , i.e., time
constraints.
• Correctness of the system depends not only on
the logical result of computation, but also on
the time at which the results are produced.
• Example: Embedded system use real time
operating system
Hard Real-Time Systems
• Hard real-time system must meet its deadline.
• Often used as a control device in a dedicated
application:
– Industrial control
– Robotics
• Secondary storage limited or absent,
data/program is stored in short term memory,
or Read-Only Memory (ROM).
Soft Real-Time Systems
• Deadlines desirable but not mandatory.
• Limited utility in industrial control or
robotics.
• Useful in modern applications (multimedia,
video conference, virtual reality) requiring
advanced operating-system features.
Multiprocessor Systems
• System with several CPUs in close communication:
– processors share memory and a clock.
– communication usually takes place through the shared
memory.
• Also known as parallel systems, tightly-coupled
systems.
• Advantages:
 Increased throughput
 Economy Of Scale
 Increased reliability
Multiprogramming vs. Multiprocessing
Types of Multiprocessor Systems
• Asymmetric Multiprocessing
– master processor schedules and allocates work to
slave processors.
Types of Multiprocessor Systems
• Symmetric Multiprocessing (SMP)
– Each processor performs all tasks within operating
system.
– No Master slave relationship.
– Most modern operating systems support SMP.
Distributed Systems
• Distributed system is collection of loosely coupled processors
interconnected by a communications network.
• Reasons for distributed systems:
– Resource sharing:
• sharing and printing files at remote sites.
• processing information in a distributed database.
• using remote specialized hardware devices.
– Computation speedup – load sharing.
– Reliability – detect and recover from site failure, function
transfer, reintegrate failed site.
– Communication – message passing.
Distributed Systems
A. Frank - P. Weisberg
Distributed Operating Systems (DOS)
• Gives the impression there is a single operating system
controlling the network.
• Data Migration – transfer data by transferring entire file, or
transferring only those portions of the file necessary for the
immediate task.
• Computation Migration – transfer the computation, rather
than the data, across the system.
• Process Migration – execute an entire process, or parts of it, at
different sites.
Operating-System Operations
• Interrupt driven by hardware
• Software error or request creates exception or trap
– Division by zero, request for operating system service
• Dual-mode operation allows OS to protect itself and
other system components
– User mode and kernel mode
– Mode bit provided by hardware
• Provides ability to distinguish when system is running user code or
kernel code
• Some instructions designated as privileged, only executable in
kernel mode
• System call changes mode to kernel, return from call resets it to
user
Transition from User to Kernel Mode
• Timer to prevent infinite loop
– Set interrupt after specific period
– Operating system decrements counter
– When counter zero generate an interrupt
Multiplexing in Resource management
• Time multiplexing
– time-sharing
– scheduling a serially-reusable resource among several users
• Eg CPU or printer
• Space multiplexing
– space-sharing
– dividing a multiple-use resource up among several users
• Eg Memory, disk space
Time-multiplexing the processor
49
Space-multiplexing memory
50
Time-multiplexing I/O devices
51
Space-multiplexing the disk
52
Download