Lect3BT200S110 - members.iinet.com.au

advertisement
Commonwealth of Australia
Copyright Regulations 1969
WARNING
This material has been copied and communicated to you
by on or behalf of Curtin University of Technology
pursuant to Part VB of the Copyright Act 1968 (the Act).
The material in this communication may be subjected to
copyright under the Act. Any further copying or
communication of this material by you may be subject of
copyright protection under the Act.
Do not remove this notice.
Copyright@SIS-TI
BT200 Lect3
1
Memory Management
Lecture 3
Copyright@SIS-TI
BT200 Lect3
2
http://upload.wikimedia.org/wikipedia/commons/thumb/b/b5/Operating_system_usage_share.svg/600pxOperating_system_usage_share.svg.png
Copyright@SIS-TI
BT200 Lect3
3
http://www.computing.dcu.ie/~humphrys/Notes/OS/Bitmaps/usage.os.2.png
Copyright@SIS-TI
BT200 Lect3
4
Kernel
Task Management: Multitasking
Memory Management: managing the system’s main
memory resources as the computers runs
Disk Management: Utilities
• Utility: A system software routine that performs a specific
support function but is not part of the resident operating system.
Four main responsibilities:
thread scheduling
interrupt and exception handling
low-level processor synchronization
Our Friend …. Kernel
recovery after a power failure
Copyright@SIS-TI
BT200 Lect3
5
Differences between File Systems
http://windowshelp.microsoft.com/Windows/en-
US/Help/5dd16a76-7224-45ed-946a-72d5c6dc6e821033.mspx
FAT32 is available only to computers running Vista, XP, 2000, windows 95,98 & me
FAT32: recommended minimum volume size is approximately 512 MB to 2 terabytes
FAT32 also has size limitations. You can’t create a FAT32 partition greater than 32 GB,
under Vista, and you cannot store a file larger than 4GB on a FAT32 partition.
FAT32: cannot be used on floppy disks
FAT32 does not have the security that NTFS provides, so if you have a FAT32 partition or
volume on your computer, any user who has access to your computer can read any file on it.
The main reason to use FAT32 is that you have a computer that will sometimes run windows
95, 98 or ME.
Copyright@SIS-TI
BT200 Lect3
6
Differences between File Systems
http://windowshelp.microsoft.com/Windows/en-US/Help/5dd16a76-7224-45ed-946a-72d5c6dc6e821033.mspx
NTFS (New Technology File System) is the preferred file system for Vista, XP,
2000, windows server 2003,2008
NTFS: recommended minimum volume size is approximately 10 Megabytes
(MB) to 2 terabytes
NTFS: cannot be used on floppy disks
NTFS has many benefits over FAT and FAT16 & 32:
• The capability to recover from some disk-related errors automatically, which FAT32 cannot.
• Improved support for larger hard disks.
• Better security because you can use permissions and encryption to restrict access to specific files
to approved users.
Copyright@SIS-TI
BT200 Lect3
7
WinFS
WinFS = is the active storage subsystem in Vista
that is used for searching, organizing and sharing
data.
WinFS = maintains a store of items and their
properties, and provides a system service in Vista to
retrieve information when it’s needed.
By using WinFS , it is easy to search files based on
their content and other criteria such as file name,
title, author, or date of publication.
WinFS: has the ability to handle large data values
WinFS: can also be used with computers running
earlier versions of windows that support the NTFS
file system.
Copyright SIS@TI
TI502 S12010
8
WinFS
Source: http://www.neowin.net/forum/index.php?showtopic=111679
WinFS: is more efficient
and effective than NTFS for
organizing, searching for,
and sharing files.
Copyright SIS@TI
WinFS is particularly useful
for storing data that needs
to be queried or shared by
users or applications.
TI502 S12010
9
Differences between 32 and 64 bits
http://www.microsoft.com/windowsxp/64bit/overview.mspx
32-bit and 64-bit refer to the way a computer's processor (also
called a CPU), handles information.
The main difference between 32 and 64 bits editions of Windows is
Memory Support.
• With more memory you can run more programs at the same time, and run more
memory intensive programs likes multimedia, gaming and database programs
• 32 bits are capable of supporting up to 4GB of system memory, with up to 2GB of
dedicated memory per process.
• 64 bits currently supports up to 128 GB of RAM, with the potential to support up to
16 terabytes of Virtual Memory as hardware capabilities and memory sizes improve.
• 64 bits: faster performance, increased reliability and greater flexibility to today's
most demanding users.
Copyright@SIS-TI
BT200 Lect3
10
Lect 3 - Objectives
 Memory Management
 Fragmentation
 Paging
 Segmentation
 Combined Segmentation and Paging
Copyright@SIS-TI
BT200 Lect3
11
Lab 3 - Objectives
 Objectives
 Managing Windows XP Hardware
 Converting a FAT drive to an NTFS Drive
 Mounting a Drive to an Empty NTFS folder
 Configuring a Quota Entry
 Group Policy
 Resource Administration
 Keyboard Options
Copyright@SIS-TI
BT200 Lect3
12
 Memory Management ?????
Copyright@SIS-TI
BT200 Lect3
13
Memory Management
Memory management “refers to the rules that govern physical and virtual
memory and allow for efficient sharing of the system's resources by user and
system processes”. (Memory Management White Pages, 1996)
Every user process under windows 2000 has it own virtual address space.
Virtual addresses are 32 bits long so each process has 4 GB of virtual
address space. (Stallings, 2009)
We have two types of memory:• Physical – Known as RAM and Main Memory
• Virtual – Known as Logical Memory or swapfile, or pagefile
Copyright@SIS-TI
BT200 Lect3
14
What is Physical Memory?
The term Physical memory is also
referred to as the main memory or
primary storage.
• Physical memory is the place “where the
computer holds current programs and data that
are in use”.
• Pcguide.com
Copyright@SIS-TI
BT200 Lect3
15
What is Virtual Memory (Also called the swapfile, Pagefile)?
A key to improving your PC’s performance is the Virtual
Memory.
When Windows gets full up on the Physical RAM Memory, it
moves to the Virtual Memory.
• “It is basically the process of using free hard disk space as a place to store data
that otherwise would be stored in your RAM. “ Windows made easy, 2002”
It is Not fast as RAM
Previously was known as Swapping, however, thesedays is
known as Paging.
Windows Made Easy issue 24
Copyright@SIS-TI
BT200 Lect3
16
Virtual Memory –using the following techniques:-
Basic Techniques:• Fragmentation
• Paging
• Segmentation
Copyright@SIS-TI
BT200 Lect3
17
Fragmentation…?????
Copyright@SIS-TI
BT200 Lect3
18
Fragmentation
Fragmentation: The word fragmentation means "the state of being
fragmented." The word fragment means "a detached, isolated or
incomplete part." It is derived from the Latin fragmentum, which in turn
is derived from frangere, meaning, "break." So fragmentation means that
something is broken into parts that are detached, isolated or incomplete.
(http://www.execsoft.com/fragbook/intro.htm)
Copyright@SIS-TI
BT200 Lect3
19
Placement Algorithm with Partitions
Equal-size partitions
• because all partitions are of equal size, it does
not matter which partition is used
Unequal-size partitions
• can assign each process to the smallest partition
within which it will fit
• queue for each partition
• processes are assigned in such a way as to
minimize wasted memory within a partition
Stallings, 2009
Copyright@SIS-TI
BT200 Lect3
20
Fixed Partitioning
Stallings, 2009
Equal-size partitions
• any process whose size is less than or equal to the
partition size can be loaded into an available
partition
• if all partitions are full, the operating system can
swap a process out of a partition
• a program may not fit in a partition. The
programmer must design the program with
overlays (check the notes)
Copyright@SIS-TI
BT200 Lect3
21
Fixed Partitioning
Stallings, 2009
Another problem associated with
equal sized partitions is that memory
use is extremely inefficient due to a
phenomenon known as internal
fragmentation. This results when a
process smaller than the partition size
is loaded into a partition. No matter
what the size of the process, it takes
up the entire partition (in the example
shown in figure 3, 512Kb is used).
Hence if a 128Kb process was loaded
into a 512Kb partition 384Kb of
memory internal to a partition is
wasted, hence the name internal
fragmentation.
Copyright@SIS-TI
BT200 Lect3
22
Unequal-size
Stallings, 2009
Internal fragmentation is reduced through
use of not only smaller, but better fitting
partitions. Using the example in figure 4, a
128Kb process would now be loaded into a
256Kb partition instead of a 512Kb
partition, reducing the wasted memory to
128Kb, a three-fold reduction in the
internal fragmentation discussed above.
The only disadvantage of unequal sized
partitioning when compared with equal
sized partitioning is that a more complex
placement algorithm is required.
Copyright@SIS-TI
BT200 Lect3
23
Dynamic Partitioning
Partitions are of variable length and number
Process is allocated exactly as much memory as required
Eventually get holes in the memory. This is called external fragmentation
Must use compaction to shift processes so they are contiguous and all free memory
is in one block The major drawback of compaction is that it is extremely
wasteful of processor time.
Stallings, 2009
Copyright@SIS-TI
BT200 Lect3
24
Summary:- Fragmentation
Fragmentation:- little chunks of unused space will be spread
throughout memory, creating a fragmentation problem.
• (Davis, 2001p.103)
Two types of Fragmentation:-
Internal
External
Copyright@SIS-TI
BT200 Lect3
25
Internal & External Fragmentation
External fragmentation
Internal fragmentation
In the memory management where the size of
memory, allocation unit is fixed
Operation system may allocate a slightly larger
amount of memory to a process. So some
memory allocated a process will be wasted.
Using smaller size of memory allocation units
could reduce internal Fragmentation
In the memory management where the size of
memory, allocation unit is variable
Operating system allocates the exact amount of
memory to each process. So there may exist many
non-contiguous free memory blocks called holes
each of which cannot fit a program. These holes are
wasted.
External fragmentation may be solved by
compaction, which moves all programs in the main
memory to a single contiguous are to create a larger
hole.
Copyright@SIS-TI
BT200 Lect3
26
Summary Memory Management
Techniques
Technique
Description
Strengths
Weaknesses
Fixed Partitioning
Main memory is divided
into a number of static
partitions at system
generation time.
A
process may be loaded
into a partition of equal
or greater size.
Simple to implement;
little operating system
overhead.
Inefficient
use
of
memory due to internal
fragmentation;
maximum number of
active processes is fixed.
Dynamic
Partitioning
Partitions are created
dynamically, so that
each process is leaded
into a partition of
exactly the same size as
that process
No
internatal
fragmentation;
more
efficient use of main
memory
Inefficient
use
of
processor due to the
need for compaction to
counter
external
fragmentation.
Copyright@SIS-TI
BT200 Lect3
Stallings 2009, Page 316
27
Paging ?????
Copyright@SIS-TI
BT200 Lect3
28
Paging
Stallings, 2009
Partition memory into small equal-size chunks and
divide each process into the same size chunks
The chunks of a process are called pages and
chunks of memory are called frames
Operating system maintains a page table for each
process
• contains the frame location for each page in the process
• memory address consist of a page number and offset within
the page
Copyright@SIS-TI
BT200 Lect3
29
Stallings, 2009
Paging
Paging is an advanced form of memory management, which makes use of virtual memory.
Paging is similar to fixed partitioning.
Physical Memory is broken into fixed-sized blocks called “Frames” Logical Memory is
broken into blocks of the same size called “Pages”
Each process is assigned a page table, which contains the page number, and the
corresponding frame number to the page's location in memory.
Paging eliminates external fragmentation completely and reduces internal
fragmentation to a bare minimum.
Copyright@SIS-TI
BT200 Lect3
30
Summary: Pages and Frames
Frames
Pages
chunks of memory are called frames.
The chunks of a process are called
pages.
Programs and data stored on disk or
divided into equal, fixed-sized
blocks called pages.
Main memory is divided into blocks of the
same size called frames. Exactly one page can
fit in one frame.
Physical Memory is broken into fixedsized blocks called “Frames”.
Logical Memory is broken into
blocks of the same size called
“Pages”.
Copyright@SIS-TI
BT200 Lect3
31
Stallings, 2009
Each process has its own page table
Each page table entry contains the frame number of the corresponding
page in main memory.
A bit is needed to indicate whether the page is in main memory or not.
Paging
Copyright@SIS-TI
BT200 Lect3
32
Page Tables
The entire page table may take up too much
main memory
Page tables are also stored in virtual
memory
When a process is running, part of its page
table is in main memory
Stallings, 2001
Copyright@SIS-TI
BT200 Lect3
33
Page Table Entries (1)
Stallings, 2009
A bit is needed in each page table entry to indicate whether
the corresponding page is present (P) in main memory or not.
If the bit indicates that the page is in memory then the entry
also includes the frame number of that page.
Copyright@SIS-TI
BT200 Lect3
34
Page Table Entries (2)
Stallings, 2009
Another control bit needed in the page table entry is a modify (
M) bit, indicating whether the contents of the corresponding
page have been altered since the page was loaded into the main
memory (if there has been no change, then it is not necessary to
write the page out when it comes time to replace the page in the
frame that it currently occupies.
Copyright@SIS-TI
BT200 Lect3
35
Page Table Entries (3)
Stallings, 2009
Other control bits may also be present, for
example, if protection for sharing is
managed at the page level, then bits for
that purpose will be required.
Copyright@SIS-TI
BT200 Lect3
36
Summary - Page Table Entries
A bit is needed to determine if page is already in
main memory (P)
Another bit is needed to determine if the page has
been modified since it was loaded in main memory
(M)
Other control bits may also be present, for example,
if protection for sharing is managed at the page
level, then bits for that purpose will be required.
Copyright@SIS-TI
BT200 Lect3
37
Page Fault
Stallings, 2009
An interrupt that occurs when a program requests data that is not
currently in Main memory. The interrupt generate the OS to
obtain the data from a storage device and load it into RAM
Invalid Page Fault: produces an error, Page fault errors can occur
for any of the following reasons:• Virtual memory system becomes unstable due to a shortage of Physical Memory
(RAM).
• Virtual memory system becomes unstable due to the shortage of free disk space.
• The Virtual memory area is corrupted by a misbehaving application.
• An application attempts to access data that is being modified by another running
application.
Copyright@SIS-TI
BT200 Lect3
38
Virtual Memory Paging
Paging Advantages
• No external fragmentation
• Higher degree of multiprogramming
• Large virtual memory space
Paging Disadvantages
• Overhead of complex memory
management
Copyright@SIS-TI
BT200 Lect3
Stallings, 2009
39
Segmentation ?????
Copyright@SIS-TI
BT200 Lect3
40
May be unequal, dynamic size
Simplifies handling of growing data structures
Allows programs to be altered and recompiled
independently
Lends itself to sharing data among processes
Lends itself to protection
Segmentation
Copyright@SIS-TI
BT200 Lect3
Stallings, 2009
41
Segmentation
Stallings, 2009
Segmentation is another virtual memory process
similar to paging.
Dynamic Partitioning – processes are divided up
into segments.
• Why Dynamic ???? ….. to ensure processes are divided up in
a more convenient place and not sliced down the middle of
two instructions that often run one after the other.
Eliminated internal fragmentation, but does
suffer from external fragmentation
Copyright@SIS-TI
BT200 Lect3
42
Segment Table Entries
Stallings, 2009
Copyright@SIS-TI
BT200 Lect3
43
Summary - Segment Table
Entries
A bit is needed to determine if segment is already in main memory (P)
Another bit is needed to determine if the segment has been modified since it
was loaded in main memory (M)
Other control bits may also be present, for example, if protection for sharing is
managed at the segment level, then bits for that purpose will be required.
Each entry contains the length of the segment (Length - specifies the length of
the segment)
Base: contains the starting physical address where the segment resides in
Copyright@SIS-TI
BT200 Lect3
44
Virtual Memory Segmentation
Advantages
•
•
•
•
No internal fragmentation
Higher degree of multiprogramming
Large virtual address space
Protection and sharing support
Disadvantages
• Overhead of complex memory management
Stallings, 2009
Copyright@SIS-TI
BT200 Lect3
45
Summary Memory Management
Techniques
Technique
Description
Strengths
Weaknesses
Simple Paging
Main
Memory
is
divided into a number
of equal size frames.
Each process is divided
into a number of equalsize pages of the same
length as frames. A
process is loaded by
loading all of its pages
into
available,
not
necessarily contiguous ,
frames.
No
External
Fragmentation
A small amount of
Internal Fragmentation
Simple
Segmentation
Each process is divided
into a number of
segments. A process is
loaded by loading all of
its
segments
into
dynamic partitions that
need not be contiguous
No
Internal
Fragmentation;
improved
memory
utilization and reduced
overhead compared to
dynamic partitioning
External
Fragmentations
Stallings 2009, Page 316
Copyright@SIS-TI
BT200 Lect3
46
Summary Memory Management
Techniques
Technique
Description
Strengths
Weaknesses
Virtual Memory
Paging
As with simple paging,
except that it is not
necessary to load all of
the pages of a process.
Non-resident pages that
are needed are brought
in later automatically.
No
external
Fragmentation; higher
degree
of
multiprogramming;
large virtual address
space
Overhead of complex
Memory Management
Virtual
Memory
Segmentation
As
with
simple
segmentation,
except
that it is not necessary
to load all of the
segments of a process.
Non-resident segments
that are needed are
brought
in
later
automatically.
No
Internal
fragmentation, higher
degree
of
multiprogramming;
large virtual address
space; protection and
sharing support
Overhead of complex
Memory Management
Copyright@SIS-TI
BT200 Lect3
Stallings 2009, Page 316
47
Combined Paging and Segmentation
Paging is transparent to the programmer
Paging eliminates external fragmentation
Segmentation is visible to the programmer
Segmentation allows for growing data structures, modularity, and support for
sharing and protection
Each segment is broken into fixed-size pages
Stallings, 2009
Copyright@SIS-TI
BT200 Lect3
48
References













Beekman, 1997 “Computer Confluence” by the Benjamin/Cummings Publishing
Company
Davis, W., Rajkumar. T., 2001 “ Operating Systems” Addison Wesley
Holcombe J., Holcombe, C., “ Survey of Operating Systems” 2003 MC-Graw Hill/
Osborne
Memory Management White Pages
(http://www.ussg.iu.edu/usail/external/tuning/mem_mgmt) 1 March 2010
Microsoft (http://www.microsoft.com) 1 March 2010
PcGuide (http://www.pcguide.com) 1 March 2010
Search Win 2000
http://searchwin2000.techtarget.com/sDefinition/0,,sid1_gci212675,00.html 1 March
2010
Shinder, T., Shinder, D., (2000) “ MCSE – Windows 2000 Professional”
Osborne/McGraw-Hill
Silberschatz, G, (2007) “Operating System Concepts” 7th Ed., John Wiley & Sons, Inc.
Techweb http://www.techweb.com 1 March 2010
Stallings, W., 2009, Operating Systems: Internals and Design Principles, Sixth Ed,
Prentice Hall.
Webopedia www.pcwebopedia.com 1 March 2010
Windows Made Easy issue 24, Paragon Publishing Limited
Copyright@SIS-TI
BT200 Lect3
49
CPU scheduling
Copyright@SIS-TI
BT200 Lect3
50
CPU scheduling goals
Fairness – in the absence of
guidance from the user or the OS,
processes should be treated the
same, and no process should suffer
starvation (a condition in which a
process is indefinitely delayed
because other processes are always
given preference).
Copyright@SIS-TI
BT200 Lect3
Stallings, 2001- Chapter 9
Balance resources – keep all
resources of the system (CPU,
Memory, disk, I/O) busy
51
Priorities
Scheduler will always choose a process of higher priority over
one of lower priority
Have multiple ready queues to represent each level of
priority
Lower-priority may suffer starvation
• allow a process to change its priority based on its age or execution history
Stallings, 2001- Chapter 9
Copyright@SIS-TI
BT200 Lect3
52
Decision Mode
Nonpreemptive (i.e. FCFS, SJF and
Priority Based) - Kernel mode Once a
process is in the running state, it will
continue until it terminates or blocks
itself for I/O
Copyright@SIS-TI
BT200 Lect3
Stallings, 2009
Preemptive (I.e. Round Robin) - User
Mode
• Currently running process may be interrupted
and moved to the Ready state by the operating
system
• Allows for better service since any one process
cannot monopolize the processor for very long
53
Types of CPU scheduling
• FCFS
• SJF
• Round-Robin
• Priority Scheduling
Copyright@SIS-TI
BT200 Lect3
54
First-Come-First-Served (FCFS)
5
0
10
15
20
1
2
3
4
5
 Each process joins the Ready queue
 When the current process ceases to execute, the oldest process in the
Ready queue is selected
Stallings, 2009
Copyright@SIS-TI
BT200 Lect3
55
AN EXAMPLE - FCFS
Source: http://www.asee.org/conferences/search/00883.pdf
Copyright@SIS-TI
BT200 Lect3
56
FCFS – Average waiting time
Process
Burst Time
P1
24
P2
3
P3
3
Suppose that the processes arrive in the order: P1, P2, P3
The Gantt chart for the schedule is:
Waiting time for P1 =0; P2 = 24; P3 =27
Average waiting time: (0 + 24 + 27)/3 = 17
Suppose that the processes arrive in the order: P2, P3, P1.
The Gantt chart for the schedule is:
Waiting time for P1 =6; P2 =0; P3 =3 Milliseconds
Average waiting time: (6 + 0 + 3)/3 = 3 Milliseconds
Much better than previous case
Copyright@SIS-TI
BT200 Lect3
57
Advantages and Disadvantages
(FCFS) - First-Come-First-Served
Stallings 2009
Simple, low overhead, small interference to processes
A short process may have to wait a very long time before it can
execute
Favors CPU-bound processes
• I/O processes have to wait until CPU-bound process completes
• Response time poor
• One process can monopolize CPU
• Overhead: The amount of processing time used by system software, such as
the operating system
Copyright@SIS-TI
BT200 Lect3
58
Stallings 2009
SJF-Shortest-Job first
Associate with each process the length of its
next CPU burst. Use these lengths to
schedule the process with the shortest time.
Other names: Shortest-Process-Next (SPN)
Copyright@SIS-TI
BT200 Lect3
59
SJF – an example
Source: http://www.asee.org/conferences/search/00883.pdf
Copyright@SIS-TI
BT200 Lect3
60
SJF – Average Waiting
Time
Example:
Process Burst Time
P1
6
P2
8
P3
7
P4
3
SJF (non-preemptive)
P4
0
P1
3
P3
9
P2
16
24
Average waiting time = (0+3+9+16)/4 = 7 Milliseconds
Copyright@SIS-TI
BT200 Lect3
61
SJF – Benefits and Shortcomings
Stallings 2009
Benefits of SJF: • Reduces average wait time and number of waiting processes
• Take always the job with the shortest run times
• Gives the minimum average waiting time for a set of
processes
Shortcomings of SJF:
• Large delay – especially for the long processes
• Waiting time is even more unpredictable than FCFS
(especially for large jobs).
• Unfair: can lead to starvation, as long job can be kept from
finishing up by short jobs
Copyright@SIS-TI
BT200 Lect3
62
Priority Scheduling
Stallings 2009
A priority number (integer) is associated with each process. The CPU is allocated to the
process with the highest priority (smallest integer => highest priority).
Priority scheduling can be either preemptive or nonpreemptive. When a process arrives at
the ready queue, its priority is compared with the priority of the currently running process
Preemptive priority scheduling algorithm: will preempt the CPU if the priority of the
newly arrived process is higher than the priority of the currently running process.
Nonpreemptive Priority scheduling: will simply put the new process at the
head of the ready queue.
Copyright@SIS-TI
BT200 Lect3
63
Stallings, 2001- Chapter 9
Priority Scheduling Problem
Problem: Starvation –
low priority processes
may never execute.
Copyright@SIS-TI
BT200 Lect3
Solution: Aging – is a
technique of gradually
increasing the priority of
processes that wait in the
system for a long time.
64
Priority Scheduling – Average waiting time
Process
Burst Time
Priority
P1
10
3
P2
1
1
P3
2
3
P4
1
4
P5
5
2
Priority Scheduling (non-preemptive)
P2
0
P5
1
P1
6
P3
16
P4
18
19
Average waiting time = (0+1+6+16+18)/5 = 8.2 Milliseconds
Copyright@SIS-TI
BT200 Lect3
65
Stallings 2009
Round-Robin (RR)
5
0
10
15
20
1
2
3
4
5
 Uses preemption based on a clock
 An amount of time is determined that allows each process to use the
processor for that length of time
Copyright@SIS-TI
BT200 Lect3
66
Round-Robin (RR)
Known as time
slicing
Clock interrupt
is generated at
periodic
intervals
When an
interrupt
occurs, the
currently
running process
is placed in the
read queue
• Next ready job is
selected
Stallings, 2001- Chapter 9
Copyright@SIS-TI
BT200 Lect3
67
RR – An Example
Example: RR with Time Quantum = 4
Process
Burst Time
P3
3
P2
3
P1
24
RR (preemptive)
P3
0
P1
P2
3
6
P1
10
P1
P1
P1
P1
14
18
22
26
30
The average waiting time is = (0+3+6) / 3 =3 milliseconds
Copyright@SIS-TI
BT200 Lect3
68
RR – An example
Source: http://www.asee.org/conferences/search/00883.pdf
Copyright@SIS-TI
BT200 Lect3
69
RR - Benefits and Shortcomings
Stallings 2009
Benefits of RR:
• Give everyone a share, better response time, no bias to a
particular type of process
• Can prevent infinite loop process to tie up the whole system
• Issues: choice of time-slice. Too small means too much time
switching, too big means poor response. Usually, context
switch switching the CPU to another process requires saving
the state of the old process and loading the saved state for the
new process), times are about 0.1ms and time-slices about
10ms.
Shortcomings of RR:
• A single fixed quantum may not fit different types of
processing, e.g. batch
Copyright@SIS-TI
BT200 Lect3
70
Multilevel Queue Scheduling (MQS)
Created for situations in
which processes are easily
classified into different
groups
Copyright@SIS-TI
BT200 Lect3
Stallings 2009
Processes are divided into
different queues based on
their type. (I.e. Interactive
[are programs that allow
users to enter data or
commands most popular
programs such as Word
Processing and
Spreadsheets] versus batch
system [are stored up
during working hours and
then executed during the
evening (without requiring
human contact)])
71
Source: http://cs1.mcm.edu/~rob/class/csc4340/notes/Chapt06/MultiLevel.jpg
MQS
Copyright@SIS-TI
BT200 Lect3
72
Stallings 2009
MQS – Benefits and Shortcomings
Benefits of MQS:
• Allows a process to move between queues. (Fair for I/O
bound processes, they don’t have to wait too long)
• A process that waits too long in a lower priority queue may
be moved to a higher priority queue (this to prevents
starvation)
• Flexible
Shortcomings of MQS:
• Is complex algorithm
• Moving the processes around produces more CPU
overhead
Copyright@SIS-TI
BT200 Lect3
73
References










Brad-X http://www.brad-x.com/unix/whatisfreebsd.phtml March 2010
FreeBSD http://www.freebsd.org March 2010
FreeBSD(2) http://www.freebsd.org/features.html March 2010
FreeBSD(3) http://www.freebsd.org/applications.html March 2010
Holcombe J., Holcombe, C., “ Survey of Operating Systems” 2003 MC-Graw Hill/ Osborne
Muster, J., (2002) “Unix Made Easy – Unix & Linux Basis & Beyond ” 3rd Ed., McGraw- Hill
Silberschatz, Galvin. (1994, 4ed) Operating System Concepts, Addison-Wesley Publishing Company
Silberschatz, G, (2003) “Operating System Concepts” 6th Ed., John Wiley & Sons, Inc.
Stallings, William. (2009, 6th ed) Operating Systems Internals and Design Principles, Prentice-Hall.
Websites:  CPU Scheduling http://www.isi.edu/~govindan/cs402/lectures/sched.html March 2010
 CPU Scheduling http://moonbase.wwc.edu/~aabyan/352/Scheduling.html March 2010
 CPU Scheduling http://www.cs.ucl.ac.uk/staff/S.Hailes/exercise.htm March 2010
 CPU Scheduling http://www.cs.cityu.edu.hk/~cs3102/cpu1.htm March 2010
 Estell, John, “Introduction CPU Scheduling Algorithms: The Photocopier Scenario
http://www.asee.org/conferences/search/00883.pdf March 2010
 Multilevel Queue Scheduling
http://cs1.mcm.edu/~rob/class/csc4340/notes/Chapt06/MultiLevel.jpg March 2010
 Resource containers and CPU scheduling
http://www.usenix.org/publications/library/proceedings/osdi99/full_papers/banga/banga_htm
l/node11.html March 2010
 Techweb http://www.techweb.com March 2010
Copyright@SIS-TI
BT200 Lect3
74
Download