Overview/Questions Software Categories Major Operating Systems

advertisement
Overview/Questions
CS101 Lecture 09:
Operating Systems
± What is system software and what is its role?
± How is memory shared between programs?
± How is the CPU shared between programs?
± How can we compare sharing algorithms?
± Where did operating systems come from?
Some diagrams copyright Jones and Bartlett
1
Software Categories
2
Major Operating Systems
UNIX
Created at AT&T Bell Labs in 1969
Application software
Software written to address specific needs²
needs²to
solve problems in the real world.
System software
Software that manages a computer system at a
fundamental level.
± many flavors: Linux, Solaris, BSD, Mac OSX.
Windows
Created by Microsoft in 1980s
± Originally as DOS (Diskette Operating System)
(text only), then Windows (graphical).
Users don¶t ³see´ the systems software.
3
4
1
Roles of an Operating System
Roles of an Operating System
An operating system is system software
which provides:
± instructions for booting up the computer
when it is powered on.
± the file system in which data can be stored in
secondary storage.
± management of computing hardware
± procedure and interface to launch all other
programs.
Figure 10.1
An operating system interacts
with many aspects of a computer
system.
5
Resource Management
6
Resource Management
Multiprogramming
Memory Management
The process of keeping track of what programs are in
memory and where in memory they reside.
The technique of keeping multiple programs in
main memory at the same time so that they
can compete for access to the CPU.
Process Management
A process or job is a program in execution.
How to share one set of hardware between many
programs?
CPU Scheduling
Determining which process in memory is executed by the
CPU at any given point.
Most of the roles of an operating system generally
revolve around the idea of ³sharing
³sharing nicely.´
nicely.´
7
8
2
Batch Processing
Timesharing System
The first operating system was a human operator,
operator, who
organized various jobs from multiple users into batches of
jobs that needed the same resources.
A timesharing system allowed multiple users to interact
with a computer at the same time.
All terminals connected to
one mainframe or minicomputer,
which had processor and memory.
Virtual Machine
The illusion created by a timesharing system that each user
has his/her own machine.
9
Memory Management
10
Memory Management
Operating systems must employ techniques to
Program 1:
variable min is assigned to
memory location 23,
a location relative to Program 1
± Track where and how a program resides in memory
± Convert logical addresses into physical addresses
Logical address
Location of a variable (stored value) relative to the
program making the reference to it.
Physical address
Actual address in the main memory (RAM) circuits.
11
OS must bind min (relative location 23)
to a specific physical memory address
Logical address for min (23) is bound to
physical address in memory (e.g. 20350)
before the program runs
Figure 10.3 Memory is a continuous set
of bits referenced by specific addresses
12
3
Paged Memory Management
Memory Management Techniques
Binding the process of mapping a logical memory
address to a physical memory address.
Demand Paging
An extension of paged memory management.
± unused pages are stored in secondary memory
± pages brought into main memory on demand
Paged memory management is a technique
for efficiently binding and sharing memory.
Virtual Memory
The illusion that there are no restrictions on the size
of a program¶s memory because the entire process
need not be in memory at one time.
± Process memory space is divided into pages
± Pages get loaded to physical memory frames
± Many frames loaded at the same time, even
from different processes.
± programs not limited by physical memory size
13
Paged Memory Management
14
Process Management
A page swap is the act of bringing a page from
secondary memory (e.g. disk) into main memory
Process Management
The act of managing the use of the CPU by
individual processes. Recall that a process is
a program in execution.
± often causes another page to be written back to
secondary memory.
Thrashing
Inefficient processing caused by constant page
swaps.
Process States
Processes go through several states
(waiting, ready, running«) as they execute.
15
16
4
Process Management
Process Management
There is only one CPU and therefore only
one set of CPU registers, which contain the
values for the currently executing process.
Process Control Block (PCB)
A data structure used by the OS to manage
information about a process, including
± current value of the program counter
± values of all CPU registers for the process
Figure 10.8 The process life cycle
17
Process Management
18
Process Management
Processes are tracked by state, with a list of PCBs,
one for each process in that state.
Each OS has a way to see which processes are
running, how much CPU/memory they¶re using,
and to kill an errant process:
A context switch occurs when a process is moved
to different state:
± Register values for the currently running process
are stored into its PCB.
± Its PCB is moved to the list of the state into which
it goes.
± Register values of the new process moving into the
running state are loaded into the CPU.
19
20
5
CPU Scheduling
CPU Scheduling
CPU Scheduling
The act of determining which process in the ready
state should be moved to the running state.
NonNon-preemptive Scheduling
The currently executing process gives up the CPU
voluntarily.
Preemptive Scheduling
The operating system decides to favor another process,
preempting the currently executing process.
Turnaround Time
The amount of time between when a process arrives in the
ready state the first time and when it exits the running
state for the last time.
± Many processes may be in the ready state at the
same time.
± Only one process can be in the running state, making
progress at any one time.
Which one gets to move from ready to running?
21
CPU Scheduling Algorithms
22
FirstFirst-Come, FirstFirst-Served
FirstFirst-Come, FirstFirst-Served
Processes are moved to the CPU in the order in which they
arrive in the running state.
Shortest Job Next
Process with shortest estimated running time in the ready
state is moved into the running state first.
Round Robin
Each process runs for a specified time slice and moves
from the running state to the ready state to await its next
turn if not finished.
23
Consider this set of processes, and their
respective run times.
Here¶s the order:
What is the average turnaround time?
24
6
First Come, First Served
Shortest Job Next
Completion times are as follows:
p1
140
p2
215
p3
535
p4
815
p5
940
Consider this set of processes, and their
respective run times.
Here¶s the order:
Average turnaround time is:
(140+215+535+815+940)/5 = 529
25
Shortest Job Next
What is the average turnaround time?
26
Round Robin
Every process is treated the same!
Completion times are as follows:
p2
75
p5
200
p1
340
p4
620
p3
940
Time Slice (a.k.a. quantum)
The amount of CPU time each process
receives before being preempted. When
preempted, a process:
± exits the CPU
± returns to the ready state
± allows another process its turn
Average turnaround time is:
(75+200+340+620+940)/5 = 495
27
28
7
Round Robin
Round Robin
Completion times are as follows:
p1
515
p2
315
p3
940
p4
920
p5
640
Consider this set of processes, and their
respective run times.
Quantum of 50:
Average turnaround time is:
(515+325+940+920+640)/5 = 668
What is the average turnaround time?
29
CPU Scheduling Algorithms
Brief History of Operating Systems
Multics:
Multics: Developed at MIT, AT&T, GE in
1960s to run on a mainframe computer.
Average TurnTurn-Around Times
FCFS:
SJN:
RR:
529
495
668
30
± MultiMulti-user, time sharing
± Memory mapping, multimulti-processor, etc.
(best)
(worst)
Are these algorithms fair? Why or why not?
What are the shortcomings of each?
What enhancements might you suggest?
UNIX: Developed at AT&T in 1970s
± MultiMulti-user
± CommandCommand-line interpreter (CLI)
± Became popular in academia
31
32
8
Brief History of Operating Systems
DOS (Diskette
(Diskette Operating System):
System):
CommandCommand-line Interpreter
Programs are launched and input/output
done via texttext-based interface.
± Developed for the IBM Personal Computer
± A company called Microsoft got the contract
to develop.
± ³one computer, one user, one program´
paradigm.
± CommandCommand-line interpreter
33
User Interfaces
User Interfaces
Windows, Icons, Menus, and Pointing device
Developed at Xerox PARC in 1970s:
±
±
±
±
±
34
Steve Jobs and team from Apple visited
PARC, and soon thereafter«
bitmapped graphics display
movable/resizable windows
buttons and poppop-up menus
computer ³desktop´
3 button mouse.
The Apple Lisa was released in 1983.
35
36
9
User Interfaces
User Interfaces
«and the Macintosh in 1984
Microsoft began developing Windows in 1985«
A small company called Microsoft got the contract to
develop productivity applications to be bundled with the
Macintosh.
but its popularity didn¶t really begin until 1990 with the
introduction of Windows 3.1.
37
Summary
38
Student To Dos
± The system software manages/shares
systems resources (memory, CPU time,
input/output devices) among programs.
± Memory management enables multiple
programs to share limited physical memory.
± CPU scheduling enables multiple processes to
share the CPU¶s time fairly (if not efficiently).
39
± Readings: CSI 10.1, 10.3, 10.4
± HW2 due Thursday 6/5
± Extra lab on June 18, 11am11am-noon
40
10
Download