UNIT 3 CHAPTER 5 (Memory Management)
UNIT 3 CHAPTER 5 (Memory Management)
UNIT 3 CHAPTER 5 (Memory Management)
* Status: Keeping the status of each memory location, whether it is allocated or free.
* Policy of allocation: It keeps trace of how much, where and when memory shared be allocated
to the process.
* Memory allocation: When a process require for a memory, specific locations, must be selected
and allocated as per policy above and memory status information is updated correspondingly.
* De-allocation: The allocation memory may be reclaimed by memory management.
This operation is based on the de-allocation policy. After de-allocation the status information
must be updated.
1
Operating System BCA-Department
Chapter 5 – Memory Management
2. Explain various types of memory addresses.
Classically the binding of instructions and data to memory addresses can be done at any of the
following steps:
(1)Compile time: If it is known at compile time, where the process will reside in memory, then absolute
code can be generated if at some later time, the starting location changes, then it will be necessary to
compile this code.
(2) Load time: If it is not known at compile time, where the process will reside in memory, then the compiler
must generate re-locatable code. In this case, final binding is delayed until land time, if the starting
address changes we need only to re-load the user code to incorporate this changed value.
(3)Execution time: Binding delayed until run-time, if the process can be moved during in execution from
one memory segment to another. Needs H/N support for maps (e.g. base and limit registers).
Dynamic loading refers to mapping or less often copying an executable library into a process's
memory after is has started.
*The entire program and all data of a process must be in physical memory for the process to execute.
*The size of a process is thus limited to the size of physical memory.
*To obtain better memory-space utilization, dynamic loading can be used.
*With dynamic loading, routine is not loaded until it is called.
*All routines are stored on the disk in a relocatable load format.
2
Operating System BCA-Department
Chapter 5 – Memory Management
An address generated by the CPU is commonly referred Logical Address or Virtual Address where as an
address seen by memory unit is commonly referred to as Physical address.
The compile time and load-time address-binding methods generate identical logical and physical addresses.
However, logical (virtual) and physical addresses differ in execution-time based on address-binding scheme.
The set of all the logical addresses generated by a process is called logical address space
The set of all physical addresses corresponding to these logical addresses is physical address space.
These spaces differ in execution-time address-binding.
The Run-time mapping from virtual to physical addresses is done by a hardware device called
Memory Management Unit (MMU). The mapping can be done using different methods.
if the base is at 14000, then an attempt by the user to address location 0 is dynamical relocated to location
14000; an access to location 346 is mapped to location 14346
5. What is overlays
Overlay is to keep in memory to only those instruction and data that are needed at given time when
other instruction are needed, they are loaded into space occupied is previously by instruction that are no
longer needed. overlaying means "replacement of a block of stored instructions or data with another".
Overlaying is a programming method that allows programs to be larger than the central processing units
' main memory.
3
Operating System BCA-Department
Chapter 5 – Memory Management
6. Explain SWAPPING
Swapping is a process which helps the CPU utilization, by replacing waiting processes in the main
memory with process, ready to execute, from the disk on the arrival of a new processes of high priority for
which there is no free space available, a memory manager is involved to make memory space available for
the new process. One completion of the higher priority process, the lower priority processes are swapped
In and continued. This type of swapping is known as roll out, roll in.
A processes needs to be in memory to be executed. A process how ever swapped out of memory temporarily
to a Backing store and again swapped-in into in memory for continued execution.
For example, assume a multiprogramming environment with a round robin CPU scheduling algorithm.
When a quantum expires, the memory manager will swap-out the process that just finished and swap in
another process to the memory space.
The concept of swapping has divided into two more concepts: Swap-in and Swap-out.
*Swap-out is a method of removing a process from RAM and adding it to the hard disk.
*Swap-in is a method of removing a program from a hard disk and putting it back into the main memory
or RAM.
4
Operating System BCA-Department
Chapter 5 – Memory Management
Multiple partition allocation:
In this technique, when there is several processes residing in memory at the same time, and various
processes are in the 1/p queue waiting to be brought into memory, memory allocation is divided into no. of
fixed size partitions. Each partition may contuing exactly one process. Thus the degree of multiprogramming
is bound by no. of partitions. When the partition is free a process is selected from the I/P queue, and loaded
into the free partition, when the process terminates, partition is avoidable to other processes.
8. Explain best fit, first fit and worst fit. or Dynamic Storage-Allocation Problem Compare first-fit, best-fit and
worst-fit allocation of memory.
Memory allocation is the process of assigning blocks of memory on request
First Fit: Another strategy is first fit, which simply scans the free list until a large enough hole is found.
In the first fit approach is to allocate the first free partition or hole large enough which can
accommodate the process. It finishes after finding the first suitable free partition.
Best Fit : The allocator places a process in the smallest block of unallocated memory in which it will fit.
The best fit deals with allocating the smallest free partition which meets the requirement of the
requesting process. This algorithm first searches the entire list of free partitions and considers the
smallest hole that is adequate. It then tries to find a hole which is close to actual process size needed.
Worst Fit: The memory manager places process in the largest block of unallocated memory available.
In worst fit approach is to locate largest available free portion so that the portion left will be big
enough to be useful. It is the reverse of best fit.
5
Operating System BCA-Department
Chapter 5 – Memory Management
6
Operating System BCA-Department
Chapter 5 – Memory Management
10 Define Compaction
One solution to a problem of external fragmentation is COMPACTION. The goal of compaction is to
shuffle memory contents to place all free memory together in one large block. It combines all the free areas
into one contiguous area.
Compaction is possible only if relocation is dynamic, and is done at execution time.
When swapping creates multiple holes in memory, it is possible to combine them all in one big hole by
moving all the processes downward as far as possible. This techniques is known as memory compaction.
It requires lot of CPU time.
7
Operating System BCA-Department
Chapter 5 – Memory Management
12. Explain paging.
In the paging scheme, physical memory is broken into fixed sized blocks called frames. The logical memory
is broken into blocks of same size called pages. When the process is to be executed, its pages are loaded
into any available memory frames from the backing store. The backing store is divided into fixed size
blocks that are of the same size as the memory frames.
8
Operating System BCA-Department
Chapter 5 – Memory Management
14. What is the hit ratio with respect to memory management
Hit ratio is a concept defined for any two adjacent level of memory hierarchy .
The hit ratios at successive levels are function of memory capacities, management policies and program
behavior. Hit ratios always lies between 0 to 1.
The percentage of times that a particular page number is found in the TLB is called hit ratio.
A 80% hit ratio means that we find the desired page number in the TLS 80 percent of time.
9
Operating System BCA-Department
Chapter 5 – Memory Management
10
Operating System BCA-Department