Document 6517942

Transcription

Document 6517942
Module 1: Introduction
Operating System Concepts
•
•
•
•
•
•
•
•
Module 1: INTRODUCTION
Andrzej Bednarski, Ph.D. student
Department of Computer and Information Science
Linköping University, Sweden
E-mail: [email protected]
What is an operating system?
Simple Batch Systems
Multiprogramming Batched Systems
Time-Sharing Systems
Personal-Computer Systems
Parallel Systems
Distributed Systems
Real -Time Systems
URL: http://www.ida.liu.se/~andbe
The lecture notes are mainly based on Silberschatz’s, Galvin’s and Gagne’s book (“Operating System Concepts”, 6th ed.,
Addison-Wesley, 2002). No part of the lecture notes may be reproduced in any form, due to the copyrights reserved by
Addison-Wesley. These lecture notes should only be used for internal teaching purposes at the Linköping University.
1.2
TDDB63 – Operating System Concepts –
Terminology
•
•
TDDB63 – Operating System Concepts –
1.3
A. Bednarski
What is an Operating System?
Job = program
Process = Job kept in memory, i.e. program in execution
•
A program that acts as an intermediary between an application
(or a user of a computer) and the computer hardware.
Operating system goals:
• Execute user programs and make solving user problems easier.
Job = Process
•
Make the computer system convenient to use.
+ E.g., consider assembler programming as opposed to
‘modern’ programming
•
Use the computer hardware in an efficient manner
+ E.g., consider multiprocessor systems
An operating system provides an environment within which
other programs can do useful work; the OS does not perform
any “useful” function itself.
TDDB63 – Operating System Concepts –
A. Bednarski
1.4
Distributed Real-Time Systems
TDDB63 – Operating System Concepts –
1.5
A. Bednarski
Where are OSs found?
General purpose systems
Embedded systems
Microprocessor
market shares
in 1999
99%
1%
T Safety critical applications (e.g. Drive-by-Wire):
T time constraints,
T data and control dependencies.
T Communication protocols: Time Triggered Protocol (TTP),
Controller Area Network (CAN).
TDDB63 – Operating System Concepts –
A. Bednarski
1.9
TDDB63 – Operating System Concepts –
A. Bednarski
1.10
1
Operating Systems
Computer System Components
General purpose operating systems
• Windows 95/98/2000/NT/XP
• Linux
• Sun Solaris
• HP-UX
• MacOS
1. Hardware – provides basic computing resources (CPU, memory,
I/O devices).
Application specific operating systems, e.g. real-time
• OSE-Delta
• VxWorks
• Chorus
• RT-Linux, RED-Linux
• EPOC, RT-Mach
• etc.
3. Applications programs – define the ways in which the system
resources are used to solve the computing problems of the users
(compilers, database systems, video games, business programs).
TDDB63 – Operating System Concepts –
A. Bednarski
2. Operating system – controls and coordinates the use of the
hardware among the various application programs for the various
users.
4. Users (people, machines, other computers).
1.11
TDDB63 – Operating System Concepts –
A. Bednarski
1.12
Different Views on Operating Systems
(and their Definition)
Abstract View of System Components
(i) OS as a User/Computer Interface
• Program creation
• Program execution
+ Load instructions, initialize files
• Access to I/O devices
+ Clean interface to filter details for the programmer
• Controlled access to files
+ Concept of file (formats etc), protection mechanism
• System access
• Error detection and response
+ Hardware errors, software errors...
• Accounting
TDDB63 – Operating System Concepts –
A. Bednarski
1.13
TDDB63 – Operating System Concepts –
A. Bednarski
1.14
Different Views on Operating Systems
(and their Definition)
Different Views on Operating Systems
(and their Definition)
(ii) Resource allocator – manages and allocates resources.
• Processing Elements, CPUs
• Memory
+ Volatile vs. non-volatile memory
• Devices
• Data resources
(iii) Control program – controls the execution of user programs and operations
of I/O devices.
• Unusual control mechanism
+ Control program functions in the same way as ordinary
computer software (executed by the CPU)
+ The OS frequently relinquishes control and must depend on
the processor to regain control
(iv) Kernel
• – the one program running at all times (all else being application
programs, which includes system utilities).
TDDB63 – Operating System Concepts –
A. Bednarski
1.15
TDDB63 – Operating System Concepts –
A. Bednarski
1.16
2
OS Objectives and Functions
Ease of Evolution of an Operating
System
•
Major operating systems will evolve over time for a number of reasons
•
•
Convenience
+ An OS makes (or at least should) a computer more convenient
to use
Efficiency
+ An OS allows the computer system resources to be used in an
efficient manner
Abilitiy to evolve
+ An OS should be constructed in such a way as to permit the
effective development, testing, and introduction of new
system functions without at the same time interfering with
service
Functionality and features vary from OS to OS
+ No universal definition
+ E.g., IBM AIX provided database support
TDDB63 – Operating System Concepts –
A. Bednarski
1.17
•
Hardware upgrades (issue of flexibility)
+ E.g., Faster processors, hardware memory management support, new
types of storage media
•
New hardware platforms (issue of portability)
•
New services (issue of extensibility)
+ E.g., window management system
+ E.g., multimedia requirements calling for real-time performance
•
Fixes
+ bug handling
TDDB63 – Operating System Concepts –
A. Bednarski
Simple Batch Systems
Simple Batch Systems
•
Input devices
+ Card readers
+ Tape drives
•
•
•
•
•
Output devices
+ Line printers
+ Tape drives
+ Card punches
•
•
Input: Program on cards
Output of program: result and/or memory dumps (including
registers)
•
•
•
No interaction between the user and the job
while the job is executing
TDDB63 – Operating System Concepts –
A. Bednarski
1.19
Hire an operator
User z operator
Add a card reader
Reduce setup time by batching
similar jobs
Automatic job sequencing –
automatically transfers control
from one job to another. First
rudimentary operating system.
OS always resident in main
memory
Resident monitor
+ initial control in monitor
+ control transfers to job
+ when job completes control
transfers back to monitor
TDDB63 – Operating System Concepts –
Simple Batch Systems cont’d
Disadvantages
Monitor
• Schedules the jobs
• Controls the sequence of events
-> must always be available
-> resident in main-memory
•
•
•
•
•
Desirable hardware features
+ Memory protection - user programs should not alter memory
containing monitor code
- if so, interrupt and transfer control to monitor
+ Timer - avoid a single job monopolizing the CPU
- if timer expires, interrupt and transfer control to monitor
+ Privileged instructions
+ Interrupts - flexibility in relinquishing to/ regaining control
from user programs
TDDB63 – Operating System Concepts –
A. Bednarski
1.21
•
1.18
Memory Layout for a Simple Batch System
A. Bednarski
1.20
Only sequential execution (first-come first-served)
No interaction between user and the job while the job is
executed.
Programs must be debugged off-line (from snapshot dumps).
Turnaround time long, i.e., time between job submission and job
completion.
CPU is often idle (due to the slow mechanical I/O devices)
E.g., consider reading 20 cards/sec to >1000 CPU
instructions/sec
TDDB63 – Operating System Concepts –
A. Bednarski
1.22
3
Spooling
Utilization Example
•
Spooling = Simultaneous Peripheral Operation On-Line
•
Overlap I/O of one job with computation of another job.
While executing one job, the OS:
+ Reads next job from card reader into a storage area
on the disk (job queue).
+ Outputs printout of previous job from disk to printer.
•
Used for processing data at remote sites (just need
notification when processing is complete)
•
Job pool – data structure that allows the OS to select
which job to run next in order to increase CPU
utilization.
A program processes a file of records and performs on average
100 machine instructions per record.
Time for reading one record
Execute 100 instructions
Time for writing one record
0.0015 seconds
0.0001 seconds
0.0015 seconds
CPU Utilization = 0.0001 / 0.0031 = 3.2%
TDDB63 – Operating System Concepts –
> 96% is spent on I/O (i.e., the CPU is idle a lot)
1.26
A. Bednarski
TDDB63 – Operating System Concepts –
Uniprogramming
1.27
A. Bednarski
Multi-programmed Batch Systems
Several jobs are kept in main memory at the same time, and the
CPU is multiplexed among them.
Running
Waiting
Running
Waiting
Process execution time:
CPU:
10 + 10 time units
I/O:
100 + 100 time units
I.e., I/O intensive (200/220 = 90.9%)
TDDB63 – Operating System Concepts –
1.28
A. Bednarski
TDDB63 – Operating System Concepts –
Multiprogramming with three
programs
Multiprogramming with two programs
A
B
Running
Running
Waiting
Running
A
Waiting
Running
Waiting
1.29
A. Bednarski
Running
B
Waiting
Running
C
Running
Waiting (printer)
Waiting (disk)
Waiting
Running
Running Waiting (network)
Waiting
Running
Waiting
Running Running Running Waiting Running Running Running Waiting
combined
TDDB63 – Operating System Concepts –
A. Bednarski
1.30
TDDB63 – Operating System Concepts –
A. Bednarski
1.31
4
OS Features Needed for
Multi-Programming
Advantages of Multi-programming
•
•
Decreased elapsed time
+ Sequential execution:
+ Multiprogramming:
660 time units
240 time units
Shorter turn-around time
+ Sequential execution:
A:
B:
C:
A:
B:
C:
+ Multiprogramming:
•
•
Better average response time
+ Sequential execution:
+ Multiprogramming
220
440
660
220
230
240
Avg: 440
(0+220+440) / 3 = 220 time units
(0 + 10 + 20) / 3 = 10 time units
1.32
A. Bednarski
•
•
•
•
Time sharing = multi-tasking
+ An extension to multi-programming.
+ Frequency of job switching is high, enabling the users to
interact with each program while it is running.
The CPU is multiplexed among several jobs that are kept in
memory and on disk (the CPU is allocated to a job only if the job is
in memory).
A job is swapped in and out of memory to the disk.
On-line communication between the user and the system is
provided; when the operating system finishes the execution of
one command, it seeks the next “control statement” not from a
card reader, but rather from the user’s keyboard.
On-line system must be available for users to access data and
code.
TDDB63 – Operating System Concepts –
1.34
A. Bednarski
Multi-Programming vs Time Sharing
Time Sharing
Principal objective
Maximize CPU use
Minimize response
time
Source of
instructions to OS
Job control language
provided with the job
Commands entered
at the terminal
A. Bednarski
I/O routine supplied by the OS.
•
Memory management – the OS must allocate the
memory to several jobs.
•
Job scheduling – the OS must choose which jobs
that should be loaded into main memory, assuming
that not all jobs can fit there.
•
CPU scheduling – the OS must choose among
several jobs ready to run, that is, jobs that are
already in main-memory.
•
Allocation of devices.
TDDB63 – Operating System Concepts –
A. Bednarski
1.33
•
Memory management
+ E.g, swapping, virtual memory
•
Memory protection
•
On-line file system
+ E.g., disk management system
•
Job and CPU scheduling (performed by OS) controlling concurrent
execution
+ Job synchronization and process communication
TDDB63 – Operating System Concepts –
A. Bednarski
1.35
Personal Computer Systems
Multi-Programming
TDDB63 – Operating System Concepts –
•
Requirements of Time Sharing and
Multi-Programming
Time Sharing Systems
– Interactive Computing
•
Multiprogramming = The ability of having multiple programs organized in
order to increase CPU utilization.
Avg: 230
Increased throughput
TDDB63 – Operating System Concepts –
•
1.36
•
Personal computers – computer system dedicated to a single user.
+ E.g., Sun, HP, and IBM Workstation, PC, Mac etc.
•
I/O devices – keyboards, mice, display screens, small printers.
•
User convenience and responsiveness.
•
Can adopt technology developed
for larger operating systems
•
Often individuals have sole use of
computer and do not need advanced
CPU utilization of protection features.
(However, consider multi-tasking)
TDDB63 – Operating System Concepts –
A. Bednarski
1.37
5
Migration of Operating-System
Concepts and Features
TDDB63 – Operating System Concepts –
A. Bednarski
Parallel Systems
1.38
•
Multiprocessor systems with more than one CPU in close
communication.
•
Tightly coupled system – processors share memory and a clock;
communication usually takes place through the shared memory.
•
Advantages of parallel system:
+ Increased throughput
+ Economical
Scalability of performance
Multiprocessor system vs multiple single-processor system
(reduction of hardware such as disks, controllers etc)
+ Increased reliability
graceful degradation (fault tolerance, …)
fail-soft systems (replication, …)
TDDB63 – Operating System Concepts –
A. Bednarski
1.39
Symmetric Multiprocessor
Architecture
Parallel Systems (Cont.)
•
Symmetric multiprocessing (SMP)
+ Each processor runs an identical copy of the operating system.
+ Many processes can run at once without performance
deterioration.
+ Most modern operating systems support SMP
•
Asymmetric multiprocessing
+ Each processor is assigned a specific task; master processor
schedules and allocates work to slave processors.
+ More common in extremely large systems
Observation: the notion of “processor” is relative, e.g., a PC are
normally considered to only have one CPU, but it normally has a
graphic processor, a communication processor etc, and these are
not considered to be multi-processing systems.
TDDB63 – Operating System Concepts –
A. Bednarski
1.40
TDDB63 – Operating System Concepts –
A. Bednarski
Distributed Systems
Distributed Systems (Cont.)
•
Distribute the computation among several physical processors.
•
•
Loosely coupled system – each processor has its own local
memory; processors communicate with one another through
various communications lines, such as high-speed buses or
telephone lines (LAN, WAN, MAN, Bluetooth, …).
Network Operating System
+ provides file sharing, e.g., NFS - Network File Systems
+ provides communication scheme
+ runs independently from other computers on the network
•
•
Advantages of distributed systems.
+ Resource sharing
+ Computation speed up – load sharing (migration of jobs)
+ Reliability
+ Communications
Distributed Operating System
+ less autonomy between computers
+ gives the impression there is a single operating system
controlling the network.
1.41
“The network is the computer…”
- Scott McNealy
TDDB63 – Operating System Concepts –
A. Bednarski
1.42
TDDB63 – Operating System Concepts –
A. Bednarski
1.43
6
Real-Time Systems
Summary
•
Often used as a control device in a dedicated application such as
controlling scientific experiments, medical imaging systems, industrial
control systems, and some display systems.
•
Purpose of operating systems
•
Well-defined and fixed time constraints.
•
Different types of operating systems and their complexities
•
Hard real-time system.
+ Secondary storage limited or absent, data stored in short-term
memory, or read-only memory (ROM)
+ Conflicts with time-sharing systems, not supported
by general-purpose operating systems.
•
Uniprocessor, multi-processor vs distributed systems
•
Multi-tasking vs multi-programming
•
Resource management
+ Job vs. CPU scheduling
+ Memory etc.
•
Soft real-time system
+ Limited utility in industrial control or
robotics
+ Useful in applications (multimedia, virtual
reality) requiring advanced operating
system features.
TDDB63 – Operating System Concepts –
A. Bednarski
1.44
TDDB63 – Operating System Concepts –
A. Bednarski
1.48
Recommended Reading and Exercises
•
Reading:
+ Chapter 1
•
Exercises:
+ All
TDDB63 – Operating System Concepts –
A. Bednarski
1.49
7