UNIT 5 OSY Updated
UNIT 5 OSY Updated
Memory Management
What is Memory Management
Main-Memory Management:
Primary-Memory or Main-Memory is a large array of words or bytes.
Each word or byte has its own address. Main-memory provides storage
that can be access directly by the CPU.
That is to say for a program to be executed, it must in the main
memory.
The major activities of an operating in regard to memory-
management are:
1. Keep track of which part of memory are currently being used and
by whom.
2. Decide which process are loaded into memory when memory space
becomes available
3. Allocate and De-allocate memory space as needed.
BASIC MEMORY MANAGEMENT TECHNIQUES
5. The size of each partition will be equal to the size of the process.
6. The partition size varies according to the need of the process so that the
internal fragmentation can be avoided.
7. No Internal Fragmentation
8. No Limitation on the size of the process
9. Degree of multiprogramming is dynamic
Variable Partitioning: example
Internal Fragmentation
Internal Fragmentation:
Internal fragmentation happens when the
memory is split into mounted sized blocks.
Whenever a method request for the memory,
the mounted sized block is allotted to the
method. just in case the memory allotted to the
method is somewhat larger than the memory
requested, then the distinction between allotted
and requested memory is that the Internal
fragmentation.
External Fragmentation
External Fragmentation:
0 1 2 3 4 5 6 7 8 9 10 11 12 13 14 15
0 0 1 1 1 1 0 0 1 1 1 1 1 1 0 0
WHAT IS FREE SPACE MANAGEMENT
TECHNIQUE
Linked List
In this approach, the free disk blocks
are linked together i.e. a free block
contains a pointer to the next free
block.
This approach stores the address of the free blocks in the first free block. The first
free block stores the address of some, say n free blocks. Out of these n blocks,
the first n-1 blocks are actually free and the last block contains the address of
next free n blocks.
An advantage of this approach is that the addresses of a group of free disk blocks
can be found easily.
Counting :
This approach stores the address of the first free disk block and a number n of
free contiguous disk blocks that follow the first block.
Every entry in the list would contain: Address of first free disk block A number n
Virtual Memory
Example:
It divides the physical memory into frames It divides the Computer’s physical memory and
and program’s address space into same size program’s address space into segments.
pages
Page is always of fixed block size. Segment is of variable size
The size of the page is specified by the The size of the segment is specified by the user
hardware.
It may lead to internal fragmentation as the It may lead to External fragmentation as the
page is of fixed block size. memory is filled with the variable sized blocks
Page table is used to map pages with frames Segment table is used to map segments with
from memory. physical memory.
Page table contains page number and frame Segment table contains segment number, length of
number. segment and base address of segment from
memory.
It does not support user’s view of memory It support user’s view of memory
Paging consist of Static linking & dynamic Segment consist of Dynamic Linking & Dynamic
loading Loading
What is Page Fault & Page Table
Page Fault : A page fault occurs when a program
accesses a page that has been mapped in the
address space, but has not been loaded in the
physical memory.
A page fault occurs when the page requested by a
program is not available in the memory it is called
as a page fault.
3. Bring the desired page into the (newly) free frame; update the
page and frame tables
Note now potentially 2 page transfers for page fault – increasing EAT
FIFO Page Replacement
Page fault: 9
Optimal Page Replacement
Least Recently Used (LRU)
Algorithm
Least Recently Used (LRU)
Algorithm
End of Chapter 5