0% found this document useful (0 votes)
7 views22 pages

MemoryManagement New

Memory management is crucial for efficient utilization of main memory in modern computers, involving the allocation and deallocation of memory for processes. It includes concepts such as logical and physical address spaces, static and dynamic loading, and swapping to manage multiple processes effectively. The document outlines various techniques and strategies for memory management, including the use of base and limit registers, linking methods, and partitioning schemes.

Uploaded by

sec23cb091
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as PDF, TXT or read online on Scribd
0% found this document useful (0 votes)
7 views22 pages

MemoryManagement New

Memory management is crucial for efficient utilization of main memory in modern computers, involving the allocation and deallocation of memory for processes. It includes concepts such as logical and physical address spaces, static and dynamic loading, and swapping to manage multiple processes effectively. The document outlines various techniques and strategies for memory management, including the use of base and limit registers, linking methods, and partitioning schemes.

Uploaded by

sec23cb091
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as PDF, TXT or read online on Scribd
You are on page 1/ 22

Memory Management

Main Memory
▪ is central to the operation of a Modern Computer.
▪ is a large array of words or bytes, ranging in size from hundreds of
thousands to billions.
▪ is the place where programs and information are kept when the
processor is effectively utilizing them.

▪is associated with the processor, so moving instructions and


information into and out of the processor is extremely fast.

▪ is also known as RAM (Random Access Memory). This memory is


volatile. RAM loses its data when a power interruption occurs.
Memory Management
▪ Memory management means management of main memory.
▪ task of subdividing the memory among different processes
▪ is a method in the operating system to manage operations
between main memory and disk during process execution.
▪ In a multiprogramming computer, the Operating System resides
in a part of the main memory, and the rest is used by multiple
processes.
▪ The main aim of memory management is to achieve efficient
utilization of memory.
Need for Memory management
▪ Allocate and de-allocate memory before and after
process execution.
▪ To keep track of used memory space by
processes.
▪ To minimize fragmentation issues.
▪ To proper utilization of main memory.
▪ To maintain data integrity while executing a process.
Logical and Physical Address Space

Logical Address Space:


▪ An address generated by the CPU is known as a “Logical
Address”.
▪ It is also known as a Virtual address.
▪ Logical address space can be defined as the size of the
process.
▪ A logical address can be changed.
Physical Address Space:
▪ An address seen by the memory unit (i.e. the one loaded
into the memory address register of the memory) is commonly
known as a “Physical Address”.
▪ is also known as a Real address.
▪ The set of all physical addresses corresponding to these
logical addresses is known as Physical address space.
▪ A physical address is computed by MMU.
▪ The run-time mapping from virtual to physical addresses is
done by a hardware device Memory Management Unit(MMU).
▪ The physical address always remains constant.
Base and Limit Registers
▪ A pair of base and limit registers define the logical address space
Hardware Address Protection with Base and Limit Registers
Binding of Instructions and Data to Memory

▪ Address binding of instructions and data to memory addresses can happen at


three different stages
▪ Compile time: If memory location known a priori, absolute code can be
generated; must recompile code if starting location changes
▪ Load time: Must generate relocatable code if memory location is not
known at compile time
▪ Execution time: Binding delayed until run time if the process can be
moved during its execution from one memory segment to another
▪ Need hardware support for address maps (e.g., base and limit
registers)
Multistep Processing of a User
Program
Static and Dynamic Loading
Static Loading:
▪ loading the entire program into a fixed address
▪ requires more memory space.
Dynamic Loading:
▪ The entire program and all data of a process must be in
physical memory for the process to execute
▪ size of a process is limited to the size of physical memory.
▪ To gain proper memory utilization, dynamic loading is used
▪ a routine is not loaded until it is called.
▪ All routines are residing on disk in a relocatable load format.
▪ unused routine is never loaded.
▪ is useful when a large amount of code is needed to handle it
efficiently.
Static and Dynamic Linking
Linker :
▪ is a program that takes one or more object files generated by a
compiler and combines them into a single executable file.
Static Linking:
▪ linker combines all necessary program modules into a single
executable program.
▪ there is no runtime dependency.
Dynamic Linking:
▪ dynamic linking is similar to dynamic loading.
▪ “Stub” is included for each appropriate library routine reference.
▪ A stub is a small piece of code.
▪ When the stub is executed, it checks whether the needed routine is
already in memory or not.
▪ If not available then the program loads the routine into memory.
Dynamic relocation using a relocation register
Swapping
▪ When a process is executed it must have resided in
memory.
▪ is a process of swapping a process temporarily into a
secondary memory from the main memory, which is fast
compared to secondary memory.
▪ allows more processes to run and can be fit into memory
at one time.
▪ main part of swapping is transferred time and the total time
is directly proportional to the amount of memory swapped.
▪ is also known as roll-out, or roll-in
▪ if a higher priority process arrives and wants service, the
memory manager can swap out the lower priority process
and then load and execute the higher priority process.
▪ After finishing higher priority work, the lower priority process
swapped back in memory and continued to the execution
process.
Memory Management with Monoprogramming
(Without Swapping)
▪ simplest memory management approach the memory is divided into two
section
▪ one part of the operating system
▪ second part of the user program
• operating system keeps track of the first and last location available
for the allocation of the user program
• operating system is loaded either at the bottom or at top
• Interrupt vectors are often loaded in low memory therefore, it makes
sense to load the operating system in low memory
• Sharing of data and code does not make much sense in a single
process environment
• Operating system can be protected from user programs with the help
of a fence register.
Multiprogramming with Fixed Partitions
(Without Swapping)

▪ A memory partition scheme with a fixed number of


partitions was introduced to support multiprogramming.

▪ this scheme is based on contiguous allocation

▪ Each partition is a block of contiguous memory

▪ Memory is partitioned into a fixed number of partitions.

▪ Each partition is of fixed size


OPERATING SYSTEMS

P1

P2

P3
Starting
Size of
Address of Status
Partition
Partition

0k 200k allocated

200k 100k free

300k 150k free

450k 250k allocated

You might also like