Documenti di Didattica
Documenti di Professioni
Documenti di Cultura
Virtual
Memory
Dr Damitha Kar u naratna
Univer s ity of Colombo school of computing
Operating Systems
Virtual memory
Is it necessary to load an entire
program to the memory for execution?
If the size of the program is larger than
the available memory how can it be
execute?
Operating Systems
Operating Systems
Virtual Memory
Operating Systems
Virtual memory
Virtual memory is partitioned in to equal size
pages.
Main memory is also partitions into equal size
page frames.
Size of a page = size of a page frame
Programs are also partitioned into pages at the
time of loading.
Operating Systems
Logical View
Operating Systems
Virtual Memory
Process runs on a virtual machine as defined
by the underlying hardware.
Focus is on Hardware support for a virtual
address space
virtual addresses independent of physical
memory
Key hardware component is the Memory
Management Unit (MMU)
address translation: virtual to physical
memory
ensures virtual address space protection
Operating Systems
Virtual Memory
Page
table
Keep track of
whether a
page is in a
physical
page frame
or not.
http://www.tutorialspoint.com/operating_system/os_virtual_memory.ht
m
Operating Systems
10
Virtual Addresses
Operating Systems
11
Operating Systems
12
Paging Example
Virtual
Memory
Page
0
A
B
C
d
Physical
Memory
Page
table
row 0
1
2
3
Page frame
0
A
B
C
D
C
C
E
f
C
C
E
f
row n
Page frame
3
Page
n
CPU
Operating Systems
MMU
13
14
Operating Systems
15
Virtual Memory
Allows programmers to address memory from a logical
point of view
Another layer of indirection
Operating Systems
16
Device Drivers
Device driver is a software.
The computer communicates
with peripheral devices
through device drivers.
A driver provides a software
interface to hardware devices,
enabling operating systems
and other computer programs
to access hardware functions
without knowing the precise
hardware details.
Operating Systems
Operating Systems
18
Files
A file is a named collection of related information, usually
a sequence of bytes
A file can be viewed in two different ways.
Logical (programmers) view: how the users see the file.
Liners collection of records.
Image File rows of intensity values
Linear sequence of bytes.
Operating Systems
19
File Attributes
Each file has an associated collection of
information(attributes)
file name
Owner
type (e.g., source, data, executable)
location(s) on the secondary storage.
organization (e.g. sequential, indexed, random)
access permissions who is permitted to
read/write/delete data in the file.
time and date of creation, modification, last
access
file size
Operating Systems
20
File Types
File can be classified into various types
based on the content.
Executable
Text
Source
Library
Compressed
Word Processor
Spread sheet.
21
Operating Systems
22
Directories
Directories are used to organize file to
logical categories.
A directory is a file that can be searched
for information about other files.
Entries in the directory file are created,
deleted and modified when the files they
describe are create, deleted and modified.
Operating Systems
23
Operating Systems
24
File allocation
Common file allocation techniques
Contiguous
Linked
Indexed
Typically the allocation techniques allocate
storage space on the basis of fixed size
addressable units.
Operating Systems
25
Blocks
file1
00
03
file2
12
06
file3
20
11
Operating Systems
26
Operating Systems
27
Start
Block No
No of
Blocks
file1
00
03
Operating Systems
28
Operating Systems
29
Operating Systems
30
Formatting a storage
device
Hard disks, need to be formatted before
using.
Formatting a disk configures the disk
with a file system so that OS can store
information on the disk.
Operating Systems
31
Operating Systems
32
http://windows.microsoft.com/en-us/windows-vista/comparing-ntfs-and-fat-filesystems
Operating Systems
33
Memory Fragmentation
Fragmentation is the unintentional division of
memory into many small free areas that cannot
be used effectively.
External Fragmentation total
memory space exists to satisfy a
request, but it is not contiguous.
Internal Fragmentation allocated
memory may be slightly larger than
requested memory
This size difference is in memory internal
to a partition, hence cannot be used for
34
any other process.
Operating Systems
Memory Fragmentation
.
Compaction is a technique that can be used
to deal with (external) fragmentation by moving
partitions to bring many small free areas
together to form a single large free area.
Operating Systems
35
References
Operating System Concepts by Avi Silberschat, Peter
Baer Galvin and Greg Gagne
http://codex.cs.yale.edu/avi/os-book/OS8/os8c/slide-dir/
Operating Systems
36