Operating Systems Overview - Physics, Computer Science and

Download Report

Transcript Operating Systems Overview - Physics, Computer Science and

Lecture Notes
Operating Systems
Dr. Ming Zhang
Tel: +1 (757) 594 7065
Fax: +1 (757) 594 7919
Office: Gosnold Hall 223
Email: [email protected]
URL: http://www.pcs.cnu.edu/~mzhang
http://www.DrMingZhang.com
http://j2ee.pcs.cnu.edu/moodle
Operating Systems
Subject Introduction
Dr. Ming Zhang
Contents of Operation Systems (1)
*
*
*
*
*
*
*
*
Operation System
Processes
Concurrency& UNIX Concurrency Mechanisms
Memory
- Memory Management
- Virtual Memory
Scheduling
- Uniprocessor Scheduling
- Multiprocessor Scheduling
Input/Output and Files
Distributed Systems (CPSC 450)
Security(CPSC 450)
Network Programming
Overview
Dr. Ming Zhang
Contents of Operation Systems (2)
* Processes
•
•
•
•
•
•
Process Description
Process Environment
Process Control
Threads
SMP (symmetric Multiprocessing)
Microkernel
Operating Systems
Subject Introduction
Dr. Ming Zhang
Contents of Operation Systems (3)
* Concurrency
•
•
•
•
Mutual Exclusion
Synchronization
Dead Lock
Starvation
Operating Systems
Subject Introduction
Dr. Ming Zhang
Contents of Operation Systems (4)
* Memory Management
 buddy System
 Paging
* Scheduling (Uniprocessor Scheduling)
 First-Come-First-Served (FCFS)
 Round-Robin (RR): q=1; q=4
 Shortest Process Next (SPN)
 Shortest Remaining Time (SRT)
 Highest Response Ratio Next (HRRN)
 Feedback q=1; q=2i
* Input/Output and Files
 Disk Scheduling
 Fire Organization
Network Programming
Overview
Dr. Ming Zhang
Prescribed Text
William Stalling
Operating Systems
- Internal and Design Principles
2005, Fifth Edition
Prentice Hall
INSB: 0 - 13 - 147954
Winner of the 1998 text award for the best
computer science and engineering textbook
Operating Systems
Subject Introduction
Dr. Ming Zhang
Exercises/Homework
Exercise/Homework
Operating Systems
Subject Introduction
Dr. Ming Zhang
Tests
* Test 1:
* Test 2:
* Test 3:
Operating Systems
Subject Introduction
Dr. Ming Zhang
Project: Construction of a Larger System
Programming: 2,000 -3,000 Lines
Project Report: 3,000 words
Oral Presentation: 5 minutes per person
Operating Systems
Subject Introduction
Dr. Ming Zhang
Final Examination
* Time
2.5 hours
Operating Systems
Subject Introduction
Dr. Ming Zhang
Operating Systems History
z
z
z
z
z
z
z
z
z
Operating systems
Subroutine
Batch monitor
Buffering and interrupt
Multiprogramming
Interactive timesharing
Preemptive scheduling
Distributed operating systems
Network and Computer Security
Operating System
z A program that controls the execution of
application programs
z An interface between the user and
hardware
z Masks the details of the hardware
What is an operating system?
z Hard to define precisely
because operating systems arose historically as
people needed to solve problems associated with
using computers.
z In the beginning: Expensive Hardware, Cheap
People
Goal: maximize hardware, utilization.
z Now: Cheap Hardware, Expensive People Goal:
make it easy for people to use computer
Layers and Views of a
Computer System
End
User
Programmer
Application
Programs
Utilities
Operating-System
Computer Hardware
OperatingSystem
Designer
Problem: code to manipulate
external I/O devices
Solution:
z Build a subroutine library (device drivers) to
manage the interaction with the I/O devices.
z The library is loaded into the top of memory and
stays there.
z This is the first example of something that
would grow into an operating system.
z Because the machine is so expensive, it is
important to keep it busy.
Services Provided by the
Operating System
z Program creation
y editors and debuggers
z
z
z
z
Program execution
Access to I/O devices
Controlled access to files
System access
Services Provided by the
Operating System
z Error detection and response
y internal and external hardware errors
x memory error
x device failure
y software errors
x arithmetic overflow
x access forbidden memory locations
y operating system cannot grant request of
application
Services Provided by the
Operating System
z Accounting
y collect statistics
y monitor performance
y used for billing users
Operating System
z It is actually a program
z Directs the processor in the use of system
resources
z Directs the processor when executing
other programs
z Processor stops executing the operating
system in order to execute other
programs
Operating System as a
Resource Manager
Computer System
Memory
I/O Controller
Operating
System
Software
I/O Controller
.
.
.
Programs
and Data
I/O Controller
Processor
. ..
Processor
O/S
Programs
Data
Problem: computer idles while
programmer sets things up
Solution:
z Build a batch monitor.
z Store jobs on a disk (spooling), have
computer read them in one at a time and
execute them.
z Big change in computer usage:
y debugging now done offline from print outs
and memory dumps.
y No more instant feedback.
Monitors
z Software that controls the running
programs
z Batch operating system
z Jobs are batched together
z Resident monitor is in main memory and
available for execution
z Monitor utilities are loaded when needed
Memory Layout For a
Resident Monitor
Interrupt
Processing
Device
Drivers
Job
Sequencing
Control Language
Interpreter
User
Program
Area
Monitor
Boundary
Problem: At any given time,
job is actively using either
the CPU or an I/O device,
and the rest of the machine
is idle and therefore
unutilized
Solution:
z Allow the job to overlap computation and
I/O. Buffering and interrupt handling
added to subroutine library.
Hardware Features
z Memory protection
y do not allow the memory area containing the
monitor to be altered
z Timer
y prevents a job from monopolizing the system
y an interrupt occurs when time expires
Hardware Features
z Privileged instructions
y executed only by the monitor
y an interrupt occurs if a program tries these
instructions
z Interrupts
y provides flexibility for controlling user
programs
Problem: one job can't keep
both CPU and I/O devices
busy. Get poor utilization
either of CPU or I/O devices.
Solution:
z multiprogramming - several jobs share
system. Dynamically switch from one job
to another when the running job does
I/O.
Multiprogramming or
Multitasking
Allows the processor to execute another program while
one program must wait for an I/O device.
Run
Run
Wait
Wait
Time
Run
A
Run
B
Time
Wait
Run
A
Run
B
Wait
Example
JOB1
JOB2
JOB3
Type of job
Heavy compute Heavy I/O
Heavy I/O
Duration
5 min.
15 min.
10 min.
Memory required 50K
100 K
80 K
Need disk?
No
No
Yes
Need terminal
No
Yes
No
Need printer?
No
No
Yes
Effects of Multiprogramming
Uniprogramming
Multiprogramming
Processor use
17%
33%
Memory use
30%
67%
Disk use
33%
67%
Printer use
33%
67%
Throughput rate
6 jobs/hr
12 jobs/hr
Mean response time 18 min.
10 min.
Big issue: protection
z Don't want one job to affect the results of
another.
z Memory protection and relocation added
to hardware, OS must manage new
hardware functionality.
z OS starts to become a significant software
system.
z OS also starts to take up significant
resources on its own.
Phase shift:
Computers become much
cheaper.
People costs become
significant.
z Issue: It becomes important to make
computers easier to use and to improve
the productivity of the people.
Problem: having to wait for
batch output . So, it is
important to run interactively.
But computers are still so
expensive that you can't buy
one for every person.
Solution:
z interactive timesharing.
Time Sharing
z Using multiprogramming to handle
multiple interactive jobs
z Processor’s time is shared among multiple
users
z Multiple users simultaneously access the
system through terminals
Problem:
Old batch schedulers were
designed to run a job for as
long as it was utilizing the
CPU effectively.
But now, people need
reasonable response time
from the computer.
Solution:
z Preemptive scheduling.
Scheduling and Resource
Management
z Fairness
y give equal and fair access to all processes
z Differential responsiveness
y discriminate between different classes of jobs
z Efficiency
y maximize throughput, minimize response
time, and accommodate as many uses as
possible
Phase shift:
Computers become even
cheaper.
It becomes practical to give
one computer to each user.
Issue:
z OS resource consumption becomes a big
issue
Problem:
People need to share data
and information with other
people
Solution:
z Networking, distributed operating
systems and modern operating systems
Problem:
Networking becomes very
important, and as sharing
becomes an important part
of the experience
z Issue:
z Network security
z Computer security
The major problem facing
computer science today is
how to build large, reliable
software systems.
z Operating systems are one of very few
examples of existing large software
systems.
z By studying operating systems, we may
learn lessons applicable to the construction
of larger systems.