Professional Documents
Culture Documents
OS is a resource allocator
Manages all resources.
Decides between conflicting requests for efficient and
fair resource use.
OS is a control program
Controls execution of programs to prevent errors and
improper use of the computer.
Resource Management
Process Management
Time Management (CPU and disk scheduling)
Space Management (memory and disk space)
Accounting and status information
Address space
Child duplicate of parent
Child has a program loaded into it
UNIX examples
fork system call creates new process
exec system call used after a fork to replace the
process memory space with a new program
Waiting time amount of time a process has been waiting in the ready
queue
P1 P2 P3
0 24 27 30
P2 P3 P1
0 3 6 30
Waiting time for P1 = 6; P2 = 0; P3 = 3
Average waiting time: (6 + 0 + 3)/3 = 3
Much better than previous case
Convoy effect short process behind long process
Review of Operating System Concepts 41
Disk Scheduling
The operating system is responsible for using hardware
efficiently for the disk drives, this means having a fast
access time and disk bandwidth.
Access time has two major components
Seek time is the time for the disk are to move the heads to the
cylinder containing the desired sector.
Rotational latency is the additional time waiting for the disk to
rotate the desired sector to the disk head.
Minimize seek time
Seek time seek distance
Disk bandwidth is the total number of bytes transferred,
divided by the total time between the first request for
service and the completion of the last transfer
Review of Operating System Concepts 42
Disk Scheduling (Cont.)
Head pointer 53
Hit ratio =
Example is Hydra
Assumptions:
Memory load and store are atomic
Increment and decrement at not atomic
Questions:
Who wins?
Is it guaranteed that someone wins?
What if both threads have their own CPU, running concurrently at exactly the same speed? Is
it guaranteed that it goes on forever?
What if they are sharing a CPU?
Producer-Consumer Problem
A set of producer processes supplies input to a set of consumer processes
Producers cannot produce if there is no space
Consumers cannot consume if there is no input
Two producers should not fill the same space and consumers should not consume the same
input
Readers-Writers Problem
Shared data exists
Either one writer or multiple readers can access it at one time
Writers priority gives priority to arriving writers over waiting readers
Readers priority gives priority to arriving readers over waiting writers
Deadlock Avoidance
Check each resource request and make sure that granting it will not cause deadlock.
The Bankers Algorithm is an example of deadlock avoidance
Run-Time
Ignore It
Multiprocessor (Parallel) OS
Tightly-coupled systems (shared memory, clock, often bus-
based)
Spatially adjacent processors
Interconnection network
Typically a bunch of mP in a box
Real-Time OS
Not time-sharing (non-interactive)
A set of jobs, each with a deadline
OS provides guarantees that jobs will finish by deadline
Factory floor automation, safety sytems
Multimedia OS