The document discusses storage management concepts including fragmentation and paging. It covers:
- External and internal fragmentation that can occur with fixed memory partitions.
- Paging concepts that divide memory into fixed-sized frames and logical memory into pages to avoid external fragmentation.
- Address translation using page tables to map logical addresses to physical frames.
2. HOME PREVIOUS TOPIC NEXT
PREVIOUS QUESTION PAPERS FOR OS
CPP TUTORIALS
2
3. Recap
In the last class, you have learnt
Multiple partition allocation
Allocation of memory
3
4. Objectives
On completion of this class, you will be able to
know
• Fragmentation
- External
- Internal
• Paging concepts
4
5. Multiprogramming with Fixed Partitions
Memory
0k
• Divide memory into n
OS
4k
(possible unequal)
P1
partitions
16k
• Problem: P2
– Fragmentation 64k
Free Space
P3
128k
5
6. External Fragmentation
Memory
• Enough total memory 0k
Operating
exists to satisfy a System
400k
request
P1
• But not contagious
1000k
• Results in external
P4
fragmentation 1700k
2000k Free Space
• Ex: Process size P3
2300k 560K
P1=600K, P4= 700K, 2560k
P3=300K, P5= 500K 6
7. Fixed Partitions
Memory
Ex. A Hole Size is
18,464 Free Space
18,464 bytes OS
Bytes
Process P3 request
is 18,462 bytes P1
Allocate the request
Internal
Hole of two bytes is P3 fragmentation
left (Internal
(cannot be
Fragmentation) P2
reallocated)
7
8. Fragmentation
• Disadvantage
– Block of free memory between two process can not
be used for executing the process
– Which end of the free block is allocated (top or
bottom)
– If all free blocks of memory were together several
more process can be executed
8
9. How Bad Is Fragmentation?
• Statistical arguments - Random sizes
• First-fit, Best-fit, Worst-fit
• Given N allocated blocks
• 0.5∗N blocks will be lost because of fragmentation
• Known as 50% RULE
9
10. Solution to External Fragmentation
Compaction
Shuffle memory contents to place all free memory
together in one large block as shown in slide no. 11
Compaction is not always possible
If relocation is static and is done at assembly or
load time compaction is not possible
10
11. Solution to External Fragmentation
Compaction is possible only if relocation is
dynamic and is done at execution time
I/O problem
Latch job in memory while it is involved in I/O
Do I/O only into OS buffers
11
13. Internal fragmentation
Want to also avoid internal fragmentation?
Memory is handed out in some fixed way (Power
of 2 for instance)
and requesting program doesn't use it all
13
14. Storage Management Problems
• Fixed partitions suffer from
– Internal fragmentation
• Variable partitions suffer from
– External fragmentation
• Compaction suffers from
– Overhead
14
15. Paging
• Possible solution to the external fragmentation is
use of Paging scheme
• Paging avoids the problem of fitting varying-sized
memory chunks on to backing store
• We don’t need to assign contiguous memory
chunks
• Internal fragmentation can only occur on the last
page assigned to a process
15
16. Paging
• Logical address space of a process can be
noncontiguous
• Process is allocated to physical memory whenever
the latter is available
• Divide physical memory into fixed-sized blocks called
frames
– Ex: size is power of 2, between 512 bytes and 8,192 bytes
• Divide logical memory into blocks of same size
called pages
16
17. Paging
• Keep track of all free frames
• To run a program of size n pages, need to find n
free frames and load program
• Set up a page table to translate logical to
physical addresses
• Internal fragmentation
17
19. Address Translation Scheme
• Address generated by CPU is logical address
– is divided into two parts as shown in next slide
– Page number (p) – used as an index into a page table
which contains base address of each page in physical
memory
– Page offset (d) – combined with base address to
define the physical memory address that is sent to the
memory unit
– for given logical address space 2m and page size 2n
page number page offset
p d
m-n n 19
20. Paging Hardware
Physical
Logical address Physical
address
Memory
p d f d
CPU
p
Page table
20
22. Paging Model of Logical and Physical
Memory
• Example: mapping of user view of memory to
physical memory
– Page size of 4 bytes
– Physical memory of 32 bytes ( 8 pages )
– Logical address 0, page 0, offset 0
– Indexing into page table, we get page 0 is in frame 5
– Logical address 0 maps to physical address
20(=(5X4)+0)
22
24. Summary
In this class, you have learnt
• Fragmentation
• Paging concepts
24
25. Frequently Asked Questions
1. What is external fragmentation?
2. What is internal fragmentation?
3. Define a page and a frame
4. Explain the paging hardware with a neat
diagram
25
26. Quiz
1. Enough total memory exists to satisfy a
request but not contagious results in
a) External fragmentation
b) Internal fragmentation
C) None
26
27. Quiz
2.Shuffling memory contents to place all free
memory together in one large block is called
a) Fragmentation
b) Hole
c) Compaction
d) None
27
28. Quiz
3. Fixed partitions suffer from
a) External fragmentation
b) Internal fragmentation
c) Compaction
d) None
28
29. Quiz
4. Variable partitions suffer from
a) External fragmentation
b) Internal fragmentation
c) Compaction
d) None
29
30. Quiz
5. Possible solution to the external fragmentation is
to use
a) Compaction
b) Paging scheme
C) None
30
31. Quiz
6. ___________used as an index into a page
table
a) Page offset
b) Hole
c) Page number (p)
d) None
31