Memory Management
Memory Management
Management:
Virtual Memory
1|Page
What is virtual memory?
2|Page
Eliminates external fragmentation and minimizes
internal fragmentation
Allows the sharing of code and data
Facilitates dynamic linking of program segments
Disadvantages:
Increased processor hardware costs
Increased overhead for handling paging
interrupts
Increased software complexity to prevent
thrashing
3|Page
WHAT ARE THE REASONS OF
DEVELOPING THE VIRTUAL
MEMORY?
4|Page
MEMORY ALLOCATION
5|Page
Demand Page Memory Allocation
it is a memory allocation schemes that load the pages into
memory only as they are needed, allowing jobs to be run
with less main memory
Uses the virtual memory (hard disk) as a temporary storage
of the jobs to be processed
void rectangleType::GetInput()
{
cout<<"Enter length:";
cin>>length;
cout<<"Enter width:";
cin>>width;
}
double rectangleType::ComputeResult()
{
return length*width;
}
6|Page
double rectangleType::DisplayResult() const
{
cout<<"The area of the rectangle is " << ComputeResult();
}
7|Page
The OS depends on following tables:
Job table
Page map table
Memory map table
Swapping Process
Page fault handler
Thrashing
Page fault
Status bit
Referenced bit
Modified bit
8|Page
The Working Set
Working set
Set pages residing in memory that can be accessed
directly without incurring a page fault
System must decide
9|Page
Segmented Memory Allocation
Each job is divided into several segments of different
sizes, one for each module that contains pieces to
perform related functions
Main memory is no longer divided into page frames,
rather allocated in a dynamic manner
Segments are set up according to the program’s
structural modules when a program is compiled or
assembled
#include <stdio.h>
main(){
double area;
area=GetInput();
10 | P a DisplayResult(ComputeArea(area));
ge
}
int GetInput(){
Segmented memory allocation. Job 1
includes a main program, Subroutine A, and
11 | P a g e
Subroutine B. It’s one job divided into three
segments.
M=a*j;
printf(“\n%d %d %d”, j,k,m)
}
printf(“\n”);
13 | P a g e
Segment Map Table lists details about each
segment (one for each job)
Memory Map Table monitors allocation of
main memory (one for whole system)
Segments don’t need to be stored contiguously
The addressing scheme requires segment
number and displacement
15 | P a g e
Page Map Table lists details about every
page (one for each segment)
Memory Map Table monitors the allocation
of the page frames in main memory (one for
the whole system)
16 | P a g e
Determine the frame number of the line
using the SMT and PMT
Frame number + displacement
Cache Memory
17 | P a g e
computers to connect main memory and
CPU via cache memory
Efficiency Calculation
Hit Ratio
h = (number of request found in the
cache/total number of requests) * 100
Average Access time
ta=tc + (1-h)*tm
Where:
ta=access time
tc=cache access time
h=hit ratio
tm=main memory access time
18 | P a g e
SUMMARY
Paged memory allocations allow efficient use of
memory by allocating jobs in noncontiguous memory
locations
Increased overhead and internal fragmentation are
problems in paged memory allocations
Job no longer constrained by the size of physical
memory in demand paging scheme
LRU scheme results in slightly better efficiency as
compared to FIFO scheme
Segmented memory allocation scheme solves
internal fragmentation problem
Segmented/demand paged memory allocation
removes the problems of compaction, external
fragmentation, and secondary storage handling
Associative memory can be used to speed up the
process
Virtual memory allows programs to be executed even
19 | P a g e
though they are not stored entirely in memory
Job’s size is no longer restricted to the size of main
memory by using the concept of virtual memory
20 | P a g e
21 | P a g e
22 | P a g e