OS Presentation
OS Presentation
1
Chapter Goals
• Distinguish between fixed and dynamic partitions
• Define and apply partition selection algorithms
• Explain the stages and transitions of the process life
cycle
• Explain the processing of various CPU scheduling
algorithms
2
Software Categories
Application software
Software written to address specific needs—to
solve problems in the real world
System software
Software that manages a computer system at a
fundamental level
3
Roles of an Operating System
Operating system
System software that
– manages computer resources, such as CPU,
memory and input/output devices
– provides an interface through which a human can
interact with the computer
– allows an application program to interact with
these other system resources
4
Roles of an Operating System
What operating
systems have
you used?
5
Roles of an Operating System
Booting
Hardware is wired to initially load a small set of
system instructions stored in ROM
These instructions load a larger set of
instructions from hard disk
Dual boot – Multiboot
6
Roles of an Operating System
The various roles of an operating system
generally revolve around the idea of “sharing
nicely”
An operating system manages resources, and
these resources are often shared in one way or
another among programs that want to use them
7
Resource Management
Multiprogramming
The technique of keeping multiple programs that
compete for access to the CPU in main memory at the
same time so that they can execute
Memory management
The process of keeping track of what programs are in
memory and where in memory they reside
8
Resource Management
Process
A program in execution
Process management
The act of carefully tracking the progress of a process
and all of its intermediate states
CPU scheduling
Determining which process in memory is executed by
the CPU at any given point
9
Batch Processing
The first operating system was a human operator, who organized
various jobs from multiple users into batches of jobs that needed
the same resources
10
Timesharing
Timesharing system
A system that allows multiple users to interact with a
computer at the same time
Virtualization
Virtualization is the process of running a virtual
instance of a computer system in a layer abstracted
from the actual hardware. Most commonly, it refers to
running operating systems in a virtual environment.
11
Other Factors
Real-time System
A system in which response time is crucial given the
nature of the application
Response time
the time taken to transmit the inquiry, process it by the
computer, and transmit the response back to the
terminal
Device driver
A small program that “knows” the way a particular
device expects to receive and deliver information
12
Logical/Physical address
In concrete terms:
A logical address is simply an integer value
relative to the starting point of the program
A physical address is a logical address added to
the starting location of the program in main
memory.
MMU are used to map logical to physical
addresses.
13
Memory Management
Program 1:
sum is assigned memory
location 23, a location
relative to Program 1
14
Memory Management techniques
• The memory management techniques can be classified into following main
categories:
16
Non-Contiguous memory
management schemes:
• in a Non-Contiguous memory management scheme, the program is divided
into different blocks and loaded at different portions of the memory that
need not necessarily be adjacent to one another. This scheme can be
classified depending upon the size of blocks and whether the blocks reside
in the main memory or not.
17
• A base and a limit register define a logical address
space
Base register
A register that holds the beginning address of the current
partition (the one that is running)
Limit register
A register that holds the length of the current partition
18
Partition Memory Management
Why check?
19
Hardware protection of memory
• Protection of memory space is accomplished by having the CPU hardware compare every
address generated in user mode with the registers. Any attempt by a program executing in
user mode to access operating-system memory or other users’ memory results in a trap to
the operating system, which treats the attempt as a fatal error
21
Partition Selection Algorithms
22
Process Management
Process management
The act of managing the use of the CPU by
individual processes
Recall that a process is a program in execution
23
Process Management
The Process States
What can
cause a
process to
move to
the
Waiting
state?
24
Process Management
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
– base and bound register values accounting information
Each state is represented by a list of PCBs, one for each
process in that state
25
Process Management
There is only one CPU and therefore only one set of CPU
registers, which contain the values for the currently
executing process
Each time a process is moved to the running 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
– This exchange of register information is called a context switch
26
CPU Scheduling
CPU Scheduling
The act of determining which process in the ready state
should be moved to the running state
– Many processes may be in the ready state
– Only one process can be in the running state, making
progress at any one time
27
CPU Scheduling
Nonpreemptive 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 (the total time spent between starting the process
and ending the process)
28
CPU Scheduling Algorithms
First-Come, First-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
29
First-Come, First-Served
What is the
average turn-
around time?
30
Shortest Job Next
What is the
average turn-
around time?
31
Round Robin
Every process is treated the same!
Time slice (quantum)
The amount of time each process receives
before being preempted and returned to the
ready state to allow another process its turn
32
Round Robin
Suppose the time slice is 50
First-Come, First-Served?
Shortest Job Next?
Round Robin?
34
Activity 1:
Use the following table of processes and service time. Draw Gantt charts that show turnaround time
for each process using SJN (shortest job next) and RR (round robin) CPU Scheduling. Also find
average turnaround time for each.
Process P1 P2 P3 P4 P5
Service time 120 60 180 50 300
302
35
Activity 2:
Apply First-Fit and Best-Fit Algorithm on the following jobs given along the memory set available
(fixed partitions). Fill Job Number column for your answer.
MEMORY MAP
First-Fit Best-Fit
(Job No) (Job No) First-Fit Best-Fit
(Job No) (Job No)
8 KB J1 = 4KB J3 = 6KB
8 KB
100 KB J2 = 30KB J6 = 100KB
100 KB
1024 KB J3 = 6KB J7 = 7
1024 KB
56 KB J4 = 9KB J5 = 10KB
56 KB
2 KB J8 = 2KB J8=2KB
2 KB
48 KB J5 = 10KB J2 = 30KB
48 KB
2048 KB J6 = 100KB
2048 KB
4 KB J10 = 1KB J1 = 4KB
4 KB
8 KB J9 = 5KB J9 = 5KB
8 KB
12 KB J4 = 9KB
12 KB
56 KB J10 = 1KB
56 KB
Jobs
J1 J2 J3 J4 J5 J6 J7 J8 J9 J10
4 KB 30 KB 6 KB 9 KB 10 KB 100 KB 200 KB 2 KB 5 KB 1 KB
36
Activity 3:
• If the partitions are fixed and a new job arrives
requiring 52 blocks of main memory, show memory
after using each of the following partition selection
approaches:
• a. first fit (60 Block)
• b. best fit (52 Blocks)
• c. worst fit (100 Blocks)
37
Activity 4:
• If the partitions are dynamic and a new job arrives
requiring 52 blocks of main memory, show memory
after using each of the following partition selection
approaches:
• a. first fit
• b. best fit
• c. worst fit
38
Activity 5:
• Why shouldn’t we use worst-fit partition
selection in a fixed-partition memory
management scheme?
39