UNIT 3 CHAPTER 5 (Memory Management)

Download as pdf or txt
Download as pdf or txt
You are on page 1of 10

Chapter 5 – Memory Management

Memory management can be defined as a process of utilizing memory in a efficient way.


Memory management can be divided into 3 areas as follows:

1. Hardware memory management:


Memory management at the hardware level is concerned with the electronic devices that actually
store the data. This includes things like RAM and memory caches.

2. Operating system memory management:


In the operating system, memory must be allocated to user programs and re-used by other programs
when it is no-longer required. The operating system can pretend that the computer has more memory
than it actually does, and also that each program has the machines memory to itself, both of these are
features of virtual memory systems.

3. Application memory management:


It involves supplying the memory needed for a program's objects and data structure from the limited
resources available and re-cycling the memory for re-use, when it is no longer required.

1. What are the Responsibilities of main memory management.(functions)

* 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).

3. what is Dynamic loading

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

4. What is LOGICAL AND PHYSICAL ADDRESS SPACE.

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.

The physical address space is calculated as follows:


Physical address space = Logical address space + Contents of relocation register

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.

7. Discuss partitioned memory management or Describe multiprogramming with fixed-size partitions


This is the simple technique of memory management technique. This partition technique allows
multiprogramming. Here the main memory is divided into smaller memory regions, called as partition.
Each partition can hold different user job.

We can divide partition memory allocation into as follows:


Single partition allocation:
If the operating system is low memory and the user processes are executing in high memory thus there
is necessary to save the OS code and data from change by the user processes and to protect the user
processes from one another.

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.

Working with example

5
Operating System BCA-Department
Chapter 5 – Memory Management

9. What is fragmentation? Explain their types with examples. What is fragmentation?


Explain their types with examples. Define internal and external fragmentation
Fragmentation refers to a situation when memory that is internal to a partition is not being used or when
enough total memory space exists to satisfy a request, but it is not contiguous; storage is fragmented into a
large number of holes.
The different types of memory fragmentation are:
Internal fragmentation
External fragmentation

Fragmentation can be reduced by the following three methods


* Compaction
* Paging
* Segmentation

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.

11.What is Virtual Memory


Memory is hardware that your computer uses to load the operating system and run programs.
* Computer consists of one or more RAM chips that each have several memory modules.
* The amount of real memory in a computer is limited to the amount of RAM installed.
Common memory sizes are 1GB, 2GB, and 4GB.
* Because your computer has a finite amount of RAM, it is possible to run out of memory when too many
programs are running at one time.
* This is where virtual memory comes in.
* Virtual memory increases the available memory of your computer by enlarging the "address space," or
places in memory where data can be stored.
* It does this by using hard disk space for additional memory allocation.

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.

13. Explain shared pages.

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.

15 Explain Segmentation (short note )


Segmentation is a memory management scheme in which the physical memory allocated to the process
is non-contiguous.
In segmentation logical address space is divided into number of small blocks known as segment.
Segments are of variable (unequal size) and each segment is allocated memory independently.
The responsibility for dividing the program into segments lies with the user (or compiler).
The operating system is uninvolved. Thus, segmentation supports user's view of memory.
Each segment has a name and a length. The address specify both the name and the offset within the
segment.
In segmentation, a logical address consists of two parts : segment number and offset.
An offset is the location in a distinct segment in main memory.

9
Operating System BCA-Department
Chapter 5 – Memory Management

16. Explain how segments are shared?

10
Operating System BCA-Department

You might also like