Operating Systems Definition 1: OS is the interface between the hardware and the software...
-
Upload
madeleine-burns -
Category
Documents
-
view
222 -
download
2
Transcript of Operating Systems Definition 1: OS is the interface between the hardware and the software...
Operating SystemsDefinition 1:
OS is the interface between the hardware and the software environment.
Compilers
Applications
Command Language Interpreter
Files
Hardware drivers
OS
OS Kernel
Hardware
OS is also known as: Kernel, Supervisor, Nucleus, Exec
Outline (1)
I. What is an Operating System?
II. Scheduling• Process Life Cycle• Job scheduling• Process Scheduling• Turnaround Evaluation
III. Deadlock• Necessary Conditions• Prevention• Avoidance• Detection & Recovery
Outline (2)
IV. Memory Management• Addressing • Management Techniques
V. Synchronization• Concurrency• 2- process Synchronization• Semaphores• Monitors
OS Characteristics
Desired qualities in an Operating System:
• Reliable
• Efficient
• Provide Protection
• Predictable
• Convenient
ResourcesResource:
Any object which can be allocated within a system:• Processors• Files• Memory • I/O devices• Communication network port
Definition 2:
An Operating System manages resources
OS History (1)
0-th generation: (1940 – 1950)Front panel programming
1-st generation: (1950’s)Tape contains batches of jobs
2-nd generation: (Early 1960’s)Multiprogramming
• Time sharing terminals• Device independent programs
Terms
IO-bound: A job that spends most of its time doing I/O
CPU-bound: A job that spends most of its time computing on the CPU
Multiprogramming: Rather than executing one job at a time, computer interleaves execution of multiple jobs
Multiprocessing: Executing of jobs on multiple, rather than just one, processor
OS History(2)
3-rd generation: (Mid 1960’s - mid 1970’s)
• General purpose OS (Univac, IBM/360, etc.)
• Job control Language (JCL)
• OS is software layer forming a virtual machine
• OS is one big monolithic assembly program
• Supervisor /User modes
• Multiprocessing
OS History(3)4-rd generation: (Since mid 1970’s)
•OS written in high level languages
•Multiprocessing
•OS = kernel+user processes for maintenance
•OS runs on PC’s Minicomputers
•Hardware platform portable OS’s (Mach, OSF)
•Networking support
•Virtual memory
•GUI supported on bitmapped display
OS History(4)Future generations:
• OS constructed using object-oriented paradigm?
• One OS controls multiple, networked computers?
• Notion of local vs. remote file vanishes?
• Increases network access security?
• Lightweight threads permit efficient concurrent programming?
• Software piracy protection?
Floating network licenses
• Auto update of OS, application releases over a network?
What pieces Make up an OS?•Resource managers, for:
• CPU (decides how to share CPU among processes)
•Memory (decides how to share memory)
•Disk (decides how to share disk)
• File system (creates logical file system, addressable by symbolic name, on top of disk sectors and blocks)
• Interrupt handlers and device drivers
• Command interpreter (or command shell)
• I/O routines
• Network protocols (to communicate with other machine sover network)
What happens with a computer is powered On? (1)
1. All integrated Circuits receive a reset signal
2. CPU begins fetching instructions at a pre-assigned physical address in memory. This address is the entry point of a bootstrap program in Read Only Memory (ROM)
3. Bootstrap program will:
• Optionally perform self-test (e.g., write, then read all memory locations)
(Contd…)
What happens with a computer is powered On? (2)
• Loads OS from a pre-assigned disk address into memory
• Transfer control to a pre-assigned physical address in memory, which is the entry point of the OS
4. OS now begins execution. On DOS, OS prints a command prompt. On UNIX, OS (eventually) starts a login process. (More on this at end of course.)
“Bootstrap” refers to tiny program in ROM telling computer how to load entire OS.
(What happens on a diskless workstation?)
What Does the CPU Do When It Has No Programs To Run?
The CPU always executes instructions.
The CPU will execute a tiny loop, possibly containing the “no-op” instruction, when no useful work needs execution.
An interrupt (e.g., from keyboard, disk, network) will cause the CPU to be reassigned to execute useful work.
Can a High Level Programming Language be Used to Write an OS?
Yes, if it:
• Allows processor and I/O space registers to be bound to program variables
• Allows manipulations of bits within a program variable (AND, OR, SHIFT)
• Has a facility to embed assembly code within source code
• Example: every machine uses different instructions to input, output data to disk and console
• Allows separate compilation
C language was an innovation in its time to meet these requirements
Process Life Cycle
Wait
Submit Hold
Complete
Ready
Run
Job Scheduler Process Scheduler
Part 2:Scheduling
Definitions (1)
Concurrent process execution can be:
• Interleaved, or
• Physically simultaneous
Interleaved:
Multiprogramming on uniprocessor
Physically simultaneous:
Uni – or multiprogramming on multiprocessor
(Contd…)
Definitions (2)
Process, thread, or task:
Schedulable unit of computation
Granularity:
Process “size” or computation to communication ratio
• Too small: excessive overhead
• Too large: less concurrency
Scheduling Terms (1)The OS looks at your program as a process
Program: Executable code stored on disk (static)
Process: Executable code (in memory0 that is or is awaiting execution (dynamic)
(Contd…)
Scheduling Terms (2)
Stack
Heap
Uninitialized data
Initialized R/W data
Initialized read-only data
Text
Read from disk when process starts
Process Life Cycle (1)
Hold Ready
Run
Blocked
Process Scheduler
Job Scheduler
(Contd…)
Process Life Cycle (2)
Job Scheduler: Most popular techniques:
• FIFO : First in, first out
• SJF : Shortest job first
Process scheduler:
Most popular technique is Round Robin
Give each process one time slice in turn until complete
Dark square contains fixed, maximum number of processes
Job Scheduling:SJF: Shortest Job First
Scheduling based on estimated run time.
(Estimating run time is, however, normally impossible!)
• Usually non-preemptive
• Compared to FIFO:
Reduces average waiting time
Increases variance
• Favors short jobs over long jobs
• Tends to:
Reduce number of jobs waiting, but
Increase turnaround time of long jobs
Job and Process SchedulingScheduling objectives
• Be fair to all waiting jobs or processes
(Does every job eventually run?)
• Maximize throughput
(# jobs completed/time interval)
• Minimize turnaround time
(delay from when job starts until it finishes execution)
•Balance resource usage
(CPU, memory disk all utilized 100%)
•Give preference to processes holding key resources
•Enforce priorities
Turnaround TimeLet:
N be number of jobs
Ai be arrival time of i-th job
Fi be finish time of i-th job
Ti be turnaround time of i-th job
T be turnaround time, averaged over all N jobs
Turnaround time:
Ti = Fi – Ai
T= Ti / N
Weighted Turnaround takes into account the run time of each job.
Scheduling Example 1Assume:
Batch Processing
No I/O or Memory Constraints
Job Arrives Run Time
1 10.0 2.0
2 10.1 1.0
3 10.25 0.25
When would jobs finish using:
1. FIFO ?
2. SJF ?
Example 1 – FIFO Solution
Job Arrives Start FinishTurnaround
1 10.0 10.0 12.0 2.0
2 10.1 12.0 13.0 2.9
3 10.25 13.0 13.25 3.0
====== 7.9
Average Turnaround time T = 2.63
Example 1 – SJF Solution
Job Arrives Start FinishTurnaround
1 10.0 10.0 12.0 2.0
2 10.1 12.25 13.25 3.15
3 10.25 12.0 12.25 2.0
====== 7.15
Average Turnaround time T = 2.38
Weighted Turnaround Time
Weighted Turnaround time (Wi)
Wi = Ti / Ri
Note that Wi must be equal or exceed 1
Average weighted Turnaround time W
W = Wi / N
Weighted Turnaround takes into account the run time of each job.
Scheduling Example 2 (1)
Assume:
• Multiprogramming
• FIFO Job Scheduling
• Processor Sharing Process Scheduling
(Contd…)
Scheduling Example 2 (2)Job Arrives Run Time
1 10.0 0.3
2 10.2 0.5
3 10.4 0.1
4 10.5 0.4
5 10.8 0.1
Ready / Running
Example 2 (Cont…)Time Event #Jobs Headway Time Left10.0 1 A,S 1 0.310.2 2 A,S 1 0.2 1 0.1
2 0.510.4 1 F 2 0.1 2 0.4
3 A,S 3 0.110.5 4 A,S 2 0.05 2 0.35
3 0.054 0.4
10.65 3 F 3 0.05 2 0.34 0.35
10.8 5 A,S 2 0.075 2 0.2254 0.2755 0.1
11.1 5 F 3 0.1 2 0.1254 0.175
11.35 2 F 2 0.125 4 0.0511.40 4 F 1 0.05
T and W for Example 2 Job Run Arrival Finish Ti Wi
1 0.3 10.0 10.4 0.4 1.332 0.5 10.2 11.35 1.15 2.33 0.1 10.4 10.65 0.25 2.54 0.4 10.5 11.4 0.9 2.255 0.1 10.8 11.1 0.3 3.0
=== ===== ===== 1.4 3.0 11.38
T = 0.6W = 2.276
Check:Because CPU was never idle, 1.4 + 10.0 must equal time
of last event (11.4)