lecture notes operating systems dr. ming zhang tel: +1 (757) 594 7065 fax: +1 (757) 594 7919 office:...
TRANSCRIPT
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 SystemPaging
* Scheduling (Uniprocessor Scheduling)First-Come-First-Served (FCFS)Round-Robin (RR): q=1; q=4Shortest Process Next (SPN)Shortest Remaining Time (SRT)Highest Response Ratio Next (HRRN)Feedback q=1; q=2i
* Input/Output and FilesDisk SchedulingFire Organization
Network Programming Overview Dr. Ming Zhang
Prescribed Text
William StallingOperating Systems - Internal and Design Principles2005, Fifth EditionPrentice HallINSB: 0 - 13 - 147954Winner of the 1998 text award for the best
computer science and engineering textbook
Operating Systems Subject Introduction Dr. Ming Zhang
Project: Construction of a Larger System
Programming: 2,000 -3,000 LinesProject Report: 3,000 wordsOral Presentation: 5 minutes per
person
Operating Systems Subject Introduction Dr. Ming Zhang
Operating Systems History
Operating systemsSubroutineBatch monitorBuffering and interruptMultiprogramming Interactive timesharingPreemptive schedulingDistributed operating systemsNetwork and Computer Security
Operating System
A program that controls the execution of application programs
An interface between the user and hardware
Masks the details of the hardware
What is an operating system?
Hard to define preciselybecause operating systems arose historically as people needed to solve problems associated with using computers.
In the beginning: Expensive Hardware, Cheap People
Goal: maximize hardware, utilization. Now: Cheap Hardware, Expensive People
Goal: make it easy for people to use computer
Layers and Views of a Computer System
EndUser
Programmer
Operating-System
Designer
Computer Hardware
Operating-System
Utilities
ApplicationPrograms
Problem: code to manipulate external I/O devices
Solution:Build a subroutine library (device drivers) to
manage the interaction with the I/O devices. The library is loaded into the top of memory
and stays there. This is the first example of something that
would grow into an operating system. Because the machine is so expensive, it is
important to keep it busy.
Services Provided by the Operating System
Program creation editors and debuggers
Program executionAccess to I/O devicesControlled access to filesSystem access
Services Provided by the Operating System
Error detection and response internal and external hardware errors
memory errordevice failure
software errorsarithmetic overflowaccess forbidden memory locations
operating system cannot grant request of application
Accounting collect statistics monitor performance used for billing users
Services Provided by the Operating System
Operating System
It is actually a programDirects the processor in the use of
system resourcesDirects the processor when
executing other programsProcessor stops executing the
operating system in order to execute other programs
Operating System as a Resource Manager
Processor . . .
.
.
.
Computer System
I/O Controller
Processor
I/O Controller
I/O Controller
Memory
OperatingSystemSoftware
Programsand Data
O/SPrograms
Data
Problem: computer idles while programmer sets things up
Solution:Build a batch monitor. Store jobs on a disk (spooling), have
computer read them in one at a time and execute them.
Big change in computer usage: debugging now done offline from print
outs and memory dumps. No more instant feedback.
Monitors
Software that controls the running programs
Batch operating systemJobs are batched togetherResident monitor is in main memory
and available for executionMonitor utilities are loaded when
needed
Memory Layout For a Resident Monitor
Boundary
InterruptProcessing
DeviceDrivers
JobSequencing
Control LanguageInterpreter
UserProgram
Area
Monitor
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: Allow the job to overlap computation and
I/O. Buffering and interrupt handling added to subroutine library.
Hardware Features
Memory protection do not allow the memory area
containing the monitor to be alteredTimer
prevents a job from monopolizing the system
an interrupt occurs when time expires
Hardware Features
Privileged instructions executed only by the monitor an interrupt occurs if a program tries
these instructionsInterrupts
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: multiprogramming - several jobs share
system. Dynamically switch from one job to another when the running job does I/O.
Allows the processor to execute another program while one program must wait for an I/O device.
Run RunWait
Time
Wait
RunA
RunAWait
Time
WaitRunB
RunB
Multiprogramming or Multitasking
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
Don't want one job to affect the results of another.
Memory protection and relocation added to hardware, OS must manage new hardware functionality.
OS starts to become a significant software system.
OS also starts to take up significant resources on its own.
Phase shift: Computers become much cheaper.People costs become significant.
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: interactive timesharing.
Time Sharing
Using multiprogramming to handle multiple interactive jobs
Processor’s time is shared among multiple users
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: Preemptive scheduling.
Scheduling and Resource Management
Fairness give equal and fair access to all processes
Differential responsiveness discriminate between different classes of
jobsEfficiency
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:OS resource consumption becomes a
big issue
Problem:People need to share data and information with other people
Solution: Networking, distributed operating
systems and modern operating systems
Problem:Networking becomes very important, and as sharing becomes an important part of the experience
Issue:Network securityComputer security