0% found this document useful (0 votes)
5 views

Unit 05 OSY (22516)

This document covers various memory management techniques, including partitioning (fixed and variable), free space management (bitmap and linked list), virtual memory, paging, segmentation, and fragmentation. It explains the advantages and disadvantages of each technique, along with real-life examples to illustrate their concepts. Additionally, it discusses the implications of page faults in memory management.

Uploaded by

omkokate555
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)
5 views

Unit 05 OSY (22516)

This document covers various memory management techniques, including partitioning (fixed and variable), free space management (bitmap and linked list), virtual memory, paging, segmentation, and fragmentation. It explains the advantages and disadvantages of each technique, along with real-life examples to illustrate their concepts. Additionally, it discusses the implications of page faults in memory management.

Uploaded by

omkokate555
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/ 18

❖ UNIT 05.

MEMORY MANAGEMENT (22516)

❖ Basic Memory Management - Partitioning


Definition and Explanation

• Partitioning is a memory management technique where memory is divided into sections


(partitions) to allocate space to multiple processes.

• There are two main types of partitioning: Fixed Partitioning and Variable Partitioning.

• Partitioning helps the operating system manage memory more effectively and assign space
to different programs.

1. Fixed Partitioning
i) Explanation
o In Fixed Partitioning, memory is divided into fixed-size partitions when the system is started.
o Each partition can hold only one process, and partitions remain the same size, regardless of
the process size.
o Drawback: Fixed sizes can lead to internal fragmentation if a process does not use up the full
partition.
ii) Diagram of Fixed Partitioning

Fig.(a) Fixed Partitioning


iii) Advantages of Fixed Partitioning
o Simple to Implement: Easy to set up and manage as partitions are fixed.
o Efficient for Small Systems: Works well when running a limited number of fixed-size
programs.
o Fast Allocation: Allocation is quick because the partitions are predetermined.
iv) Disadvantages of Fixed Partitioning
o Internal Fragmentation: Unused space within fixed-size partitions wastes memory.
o Inflexible: Fixed partitions cannot adapt to processes of varying sizes.
o Limited Scalability: Not suitable for systems running many or dynamic processes.

Diploma Helper. Feel free to join us at. 8698079745


❖ UNIT 05. MEMORY MANAGEMENT (22516)

2. Variable Partitioning
i) Explanation
o In Variable Partitioning, memory is divided into variable-sized partitions based on the
size of each process.
o When a process is loaded, it occupies only the space it needs, and unused memory is
divided into differently sized blocks.
o Drawback: Can lead to external fragmentation as free memory becomes scattered.
ii) Diagram of Variable Partitioning

Fig.(b) Variable/Dynamic Partitioning


iii) Advantages of Variable Partitioning
o Efficient Memory Use: Allocates only the required space for each process, reducing
internal fragmentation.
o Flexible: Can adapt to processes of various sizes.
o Scalable for Large Systems: Ideal for systems with dynamic memory demands.
iv) Disadvantages of Variable Partitioning
o External Fragmentation: Free memory blocks can become scattered, making allocation
for large processes challenging.
o Complex Management: More complex to manage than fixed partitioning.
o Slower Allocation: Allocating variable partitions requires more processing time.
Real-Life Example
• Fixed Partitioning: Like a movie theater with fixed-size seats – each seat is the same size, but
some seats may be too big or small for different people, leading to wasted space.
• Variable Partitioning: Like a parking lot with different-sized spaces for cars of various sizes,
but gaps between cars may prevent efficient use of all space.

Diploma Helper. Feel free to join us at. 8698079745


❖ UNIT 05. MEMORY MANAGEMENT (22516)

❖ Free Space Management Techniques


Definition and Explanation

o Free space management techniques are used to keep track of unallocated (free) memory
areas in the storage.
o These techniques help in efficiently allocating and deallocating memory, reducing wastage
and improving performance.

1. Bitmap
i) Explanation
o In the Bitmap method, free and allocated memory blocks are represented using bits in a
bitmap (an array of bits).
o Each bit in the bitmap represents a memory block:
• 0 indicates a allocated block.
• 1 indicates an free block.
ii) How It Works
1. The memory is divided into fixed-size blocks.
2. Each block’s status (free or allocated) is represented by a bit in the bitmap.
3. The operating system scans the bitmap to find free blocks for allocation.
iii) Diagram
o consider a disk where blocks
o 2, 3, 4, 5, 8, 9, 10, 11, 12, 13 are free and the rest of the blocks are allocated.
o The free-space bit map would be : 0011110011111100

Fig.(c) Bitmap
iv) Advantages
o Efficient for small block allocations, as each bit represents only one block.
o Quick to search for available memory if the bitmap is small.
v) Disadvantages
o Inefficient if blocks are large, as searching for a sequence of free bits can be slow.
o The bitmap itself consumes memory, especially if there are many blocks.

Diploma Helper. Feel free to join us at. 8698079745


❖ UNIT 05. MEMORY MANAGEMENT (22516)

2. Linked List
i) Explanation

o In the Linked List method, free memory blocks are stored as nodes in a linked list.

o Each node represents a free block, containing pointers to the next free block, creating a
chain.

ii) How It Works

1. The list starts with a pointer to the first free block in memory.

2. Each node in the list points to the next free block.

3. When a block is allocated or freed, the list is updated to reflect changes in available
memory

iii) Diagram

Fig.(d) Linked list

iv) Advantages

o Easily adapted for variable-sized memory blocks, as each node can represent blocks of
different sizes.

o No memory wasted, as only free blocks are represented in the list.

v) Disadvantages

o Searching for a suitable free block may be slower in long lists.

o Requires extra memory for pointers, increasing overhead.

Diploma Helper. Feel free to join us at. 8698079745


❖ UNIT 05. MEMORY MANAGEMENT (22516)

Diagram Explanation (both)

o Bitmap: Each bit shows whether the corresponding memory block is free (0) or allocated (1).

o Linked List: Each node points to the next free memory block, forming a linked chain of free
blocks.

Real-Life Example (both)

o Bitmap: Imagine a parking lot where each parking spot is represented by a light: a green light
(0) means the spot is empty, while a red light (1) means it’s occupied.

o Linked List: Think of a line of vacant hotel rooms where each room card has information
about the next available room. When one room is occupied, the list updates to skip over it.

❖ Virtual Memory
i) Definition and Explanation
o Virtual Memory is a memory management technique that allows programs to use more
memory than what is physically available on the system.
o It uses a combination of physical RAM and disk space (secondary storage) to create an
extended memory environment.
o This enables large applications to run smoothly even if the system’s physical memory
(RAM) is limited.
ii) Real-Life Example
o Virtual Memory Example: When you open multiple large applications (e.g., a web
browser, word processor, and video editor) on a system with limited RAM, virtual
memory allows the OS to keep some parts on disk until you actively use them.
iii) Advantages of Virtual Memory
o Allows Large Applications: Enables programs to run even if they need more memory
than physically available.
o Efficient Memory Use: Only active pages remain in RAM, optimizing memory usage.
o Supports Multitasking: Makes it possible to run multiple applications simultaneously.
iv) Disadvantages of Virtual Memory
o Slower Performance: Swapping between RAM and disk (known as paging) can slow
down the system.
o Increased Disk Usage: Constant swapping uses disk space and may reduce disk lifespan.
o Page Faults: When a required page is not in memory, a page fault occurs, causing a delay
as it is fetched from disk.

Diploma Helper. Feel free to join us at. 8698079745


❖ UNIT 05. MEMORY MANAGEMENT (22516)

❖ Paging
i) Definition and Explanation
o Paging is a memory management technique that divides logical memory (program
memory) and physical memory (RAM) into fixed-size blocks called pages and frames
respectively.
o It allows the operating system to manage memory efficiently by loading only the
necessary pages into physical memory.
o Paging helps in preventing fragmentation and makes better use of memory by loading
only needed parts of a program.
ii) How Paging Works
1. Logical Memory Pages:
o The OS divides a program's memory into equal-sized pages in the logical (virtual)
memory.
2. Physical Memory Frames:
o The physical memory is divided into fixed-size frames that match the size of the
pages in logical memory.
3. Page Table:
o A page table keeps track of each page's location, mapping logical pages to
physical frames.
o If a page is needed but not in memory, a page fault occurs, and the page is
loaded from the secondary storage.
iii) Diagram of Paging

Fig.(e) Paging

Diploma Helper. Feel free to join us at. 8698079745


❖ UNIT 05. MEMORY MANAGEMENT (22516)

iv) Diagram Explanation

o Logical Memory is divided into pages, and Physical Memory is divided into frames of the
same size.

o The Page Table maps each page in logical memory to a specific frame in physical
memory.

o When a program accesses a page that’s not loaded, it triggers a page fault to load the
page from disk.

v) Real-Life Example

o Paging Example: Think of paging like a large book with different chapters. Only the
chapters you’re reading are kept open (in memory), while the rest stay closed (on disk).
When you need a different chapter, you swap it in and put another chapter away.

vi) Advantages of Paging

o Eliminates External Fragmentation: Dividing memory into equal-sized frames prevents


wasted memory space.

o Efficient Memory Use: Only required pages are loaded into memory, saving physical
memory space.

o Supports Virtual Memory: Works well with virtual memory systems to extend the usable
memory.

vii) Disadvantages of Paging

o Page Table Overhead: Maintaining a page table for each process requires extra memory.

o Page Faults Slow Performance: Frequent page faults (loading pages from disk) can slow
down the system.

o Internal Fragmentation: If a page is not fully used, the unused part leads to internal
fragmentation.

Diploma Helper. Feel free to join us at. 8698079745


❖ UNIT 05. MEMORY MANAGEMENT (22516)

❖ Segmentation
i) Definition and Explanation
o Segmentation is a memory management technique that divides a program’s memory
into variable-sized parts called segments, based on the logical structure of the program.
o Each segment typically represents a specific functional part of a program, like code, data,
or stack.
o Unlike paging, segments are not fixed-size blocks but vary based on the program's needs,
making it a flexible way to allocate memory.
ii) How Segmentation Works
1. Segments in Logical Memory:
o The program's logical memory is divided into meaningful segments like code,
data, and stack segments.
2. Segment Table:
o Each process has a segment table that keeps track of each segment’s base
address (starting point) and limit (size).
o The operating system uses this table to map logical addresses to physical
addresses.
3. Address Translation:
o When accessing memory, the logical address is translated into a physical address
using the segment’s base address and offset within that segment.
iii) Diagram of Segmentation

Fig.(f) Segmentation

Diploma Helper. Feel free to join us at. 8698079745


❖ UNIT 05. MEMORY MANAGEMENT (22516)

iv) Diagram Explanation

• Logical Memory is divided into variable-sized segments, each serving a specific purpose.

• The Segment Table contains the base address and limit for each segment.

• The Physical Memory contains these segments in contiguous blocks, but they do not
have to be in order.

v) Real-Life Example

• Segmentation Example: Think of a university library with different sections for various
subjects (Science, Literature, History). Each section is of different size, based on the
number of books it contains, just like segments are of variable size based on data
requirements.

vi) Advantages of Segmentation

1. Logical Division of Memory: Segments align with program structure (code, data), making
memory management more intuitive.

2. Efficient Use of Memory: Segments are sized according to actual program needs,
reducing memory wastage.

3. Protection and Sharing: Segments allow better protection and can be shared between
processes, improving efficiency.

vii) Disadvantages of Segmentation

1. External Fragmentation: Variable-size segments can lead to fragmented memory, making


it difficult to allocate contiguous space.

2. Segment Table Overhead: Each process requires a segment table, increasing memory
usage and complexity.

3. Complex Memory Management: Managing variable-sized segments is more complex


than fixed-size paging.

Diploma Helper. Feel free to join us at. 8698079745


❖ UNIT 05. MEMORY MANAGEMENT (22516)

❖ Paging vs Segmentation

Diploma Helper. Feel free to join us at. 8698079745


❖ UNIT 05. MEMORY MANAGEMENT (22516)

❖ Fragmentation
i) Definition and Explanation
o Fragmentation is a memory management problem that occurs when free memory is
divided into small, scattered blocks, making it difficult to allocate memory for new
processes.
o It happens when memory blocks are not contiguous, leading to inefficient memory use.
o Fragmentation is mainly of two types: External Fragmentation and Internal
Fragmentation.
ii) Types of Fragmentation
1. External Fragmentation
o Occurs when free memory is split into small, non-contiguous blocks outside
allocated memory.
o It prevents large processes from fitting into memory, even if the total free space
is enough.
o Example: Imagine free spaces scattered across memory but not enough
continuous space for a large program.
2. Internal Fragmentation
o Happens when allocated memory blocks have unused space inside them.
o Occurs due to fixed-size memory allocation, where some space within a block
remains unused.
o Example: If a process needs 12 KB, but a 16 KB block is allocated, the extra 4 KB
goes unused.
iii) Diagram of Fragmentation

Fig.(g) Internal Fragmentation

Diploma Helper. Feel free to join us at. 8698079745


❖ UNIT 05. MEMORY MANAGEMENT (22516)

Fig.(h) External Fragmentation

iv) Diagram Explanation


o External Fragmentation is shown as free memory blocks scattered between allocated
memory blocks.
o Internal Fragmentation is shown as unused space within allocated memory blocks.
v) Real-Life Example
o Example of Fragmentation: Think of a parking lot where spaces are irregularly available.
Even if the total space is enough for a bus, scattered smaller spaces prevent it from
parking (external fragmentation). If cars park in oversized spots, some space remains
unused (internal fragmentation).
vi) Advantages of Understanding Fragmentation
1. Improves Memory Allocation: Helps in choosing efficient memory management
techniques.
2. Reduces Waste: Identifying fragmentation allows better utilization of memory.
3. Optimizes System Performance: Helps in understanding when to use defragmentation.
vii) Disadvantages of Fragmentation
1. Inefficient Memory Use: Memory blocks become wasted, reducing available space.
2. Reduces System Performance: High fragmentation slows down system operations.
3. Frequent Reallocations Needed: Managing fragmented memory requires more
reallocation efforts.
4. Limits Large Allocations: Fragmentation can prevent large processes from running due to
scattered memory.

Diploma Helper. Feel free to join us at. 8698079745


❖ UNIT 05. MEMORY MANAGEMENT (22516)

❖ Page Fault
i) Definition and Explanation
o A Page Fault occurs when a program tries to access a page that is not currently loaded
into the main memory (RAM).
o When a page fault happens, the operating system must retrieve the page from
secondary storage (e.g., a hard drive) and load it into memory.
o Page faults are a normal part of memory management in systems with virtual memory,
but too many page faults can slow down the system.
ii) Steps Involved in Handling a Page Fault
1. Check Page Table:
o The OS checks the page table to confirm that the requested page is not in
memory.
2. Bring Page from Disk:
o The required page is retrieved from secondary storage and loaded into an
available frame in physical memory.
3. Update Page Table:
o The OS updates the page table with the new page’s location in memory.
4. Restart Instruction:
o The process that caused the page fault restarts from where it left off, now with
the requested page in memory.
iii) Real-Life Example
o Page Fault Example: Imagine opening a file from your computer that hasn’t been loaded
into memory yet. The system retrieves the file from the disk (secondary storage) and
loads it into memory, so you can access it.
iv) Advantages of Page Faults
1. Efficient Memory Use: Only required pages are loaded, saving memory space.
2. Supports Large Applications: Allows programs larger than the available RAM to run.
3. Reduces Initial Load Time: Programs load only necessary parts, improving start times.
4. Enhanced Multitasking: Helps manage multiple programs effectively by loading pages as
needed.
v) Disadvantages of Page Faults
1. Slows System Performance: Excessive page faults cause delays due to loading from disk.
2. Increases Disk Usage: Frequent page faults increase disk read/write activity.
3. Causes Thrashing: Too many page faults can lead to thrashing, where the system spends
more time swapping pages than executing.
4. Requires Page Replacement: If memory is full, a page replacement algorithm is needed,
adding complexity

Diploma Helper. Feel free to join us at. 8698079745


❖ UNIT 05. MEMORY MANAGEMENT (22516)

❖ Page Replacement Algorithms

Definition and Explanation

o Page replacement algorithms are used in memory management to decide which pages
(data) to remove from memory when new pages need to be loaded.

o These algorithms ensure efficient use of memory, especially in systems with limited physical
memory.

Types of Page Replacement Algorithm

1. First-Come , First-Served(FCFS)

2. Least Recently Used (LRU)

3. Optimal Page Replacement

1. First-Come, First-Served (FCFS)


Explanation
o Pages are replaced in the order they were loaded, regardless of usage.
o The oldest page in memory is removed to make space for a new page.
Steps:
1. When a new page arrives, check if there’s space in memory.
2. If memory is full, remove the page that was loaded first (oldest).
3. Load the new page into memory.
Advantages
o Simple to implement and understand.
o Suitable for systems where page usage patterns are predictable.
Disadvantages
o Doesn’t consider page usage frequency, leading to poor performance.
o Can cause unnecessary page faults if older pages are still in use.

Diploma Helper. Feel free to join us at. 8698079745


❖ UNIT 05. MEMORY MANAGEMENT (22516)

2. Least Recently Used (LRU)


Explanation
o Replaces the least recently used page in memory.
o Tracks when each page was last used and removes the one that hasn’t been used for the
longest time.
Steps:
1. When a new page arrives, check if there’s space in memory.
2. If memory is full, identify the page that hasn’t been used in the longest time.
3. Remove that page and load the new page into memory.
Advantages
o Considers usage patterns, often leading to better performance.
o Frequently used pages are less likely to be replaced, reducing page faults.
Disadvantages
o Requires tracking page usage, which can add overhead.
o More complex to implement than FCFS.

3. Optimal Page Replacement


Explanation
o Replaces the page that won't be used for the longest time in the future.
o Ideal algorithm but requires knowledge of future page requests, making it impractical for
real-time use.
Steps:
1. When a new page arrives, check if there’s space in memory.
2. If memory is full, identify the page that won’t be needed soonest.
3. Remove that page and load the new page into memory.
Advantages
o Offers the best possible performance and minimizes page faults.
o Useful as a benchmark for evaluating other algorithms.
Disadvantages
o Requires future knowledge of page requests, which is impractical in most cases.
o Used mostly in theoretical or simulated scenarios.

Diploma Helper. Feel free to join us at. 8698079745


❖ UNIT 05. MEMORY MANAGEMENT (22516)

All Explanation (short)

• FCFS: Removes the page that was loaded first.

• LRU: Removes the page that was used the longest time ago.

• Optimal: Removes the page that won’t be used for the longest future duration.

Real-Life Example

• Example of LRU: Imagine you have limited space in your phone’s memory. You open three
apps (A, B, C), and then open D. Your phone removes the app you used the longest time ago
(A) to make room for D.

• Example of Optimal: If you knew you wouldn’t use app B for a while, you’d remove it instead
of other apps you need more frequently.

Diploma Helper. Feel free to join us at. 8698079745


❖ UNIT 05. MEMORY MANAGEMENT (22516)

❖ Winter 2019
1. Define virtual memory (2marks)
2. Explain partitioning and its types (4marks)
3. Explain LRU page replacement algorithm for following reference string.
7 0 1 2 0 3 0 4 2 3 0 3 2 1 2 0 1 7 0 1 Calculate the page fault. (6marks)
4. List free space management techniques? Describe any one in detail. (6marks)

❖ Summer 2022
1. Define the term fragmentation in terms of memory (2marks)
2. With suitable diagram, describe the concept of variable partitioning of memory. (4marks)
3. With suitable example, describe any one free space management technique (4marks)
4. Describe the concept of virtual memory with respect to paging. Also draw paging hardware
diagram and describe its working with example. (6marks)
5. Consider the following page reference string arrival with three page frames:- 5, 6, 7, 8, 9, 7, 8, 5,
9, 7, 8, 7, 9, 6, 5, 6 Calculate number of page faults with optimal and FIFO (First In First Out) page
replacement algorithms. (6marks)

❖ Winter 2022
1. Differentiate between paging and segmentation. (2marks)
2. Explain fixed size memory partitioning. (4marks)
3. Describe free space management technique. (Any two). (4marks)
4. Given a page reference string with three (03) page frames. Calculate the page faults with
‘Optimal’ and ‘LRU’ page replacement algorithm respectively.
‘7,0,1,2,0,3,0,4,2,3,0,3,2,1,2,0,1,7,0,1 (6marks)

Diploma Helper. Feel free to join us at. 8698079745


❖ UNIT 05. MEMORY MANAGEMENT (22516)

❖ Summer 2023
1. Define following terms : i) Virtual Memory ii) Paging. (2marks)
2. Define fragmentation. Explain Internal and External Fragmentation. (4marks)
3. Differentiate between paging and segmentation (any 4 points). (4marks)
4. Explain fixed and variable memory management. (4marks)
5. For the page reference string 7, 0, 1, 2, 0, 3, 0, 4, 2, 3, 0, 3, 2, 1, 2, 0, 1, 7, 0, 1 Calculate the
page faults applying. i) Optimal ii) LRU iii) FiFo page (6marks)

❖ Winter 2023
1. Define paging and segmentation (2marks)
2. Describe concept of free space management technique using bit map method. (4marks)
3. Find out the total number of page faults using i) Least recently used page replacement ii)
Optimal page replacement Page replacement algorithms of memory management, if the
page are coming in the order 7 0 1 2 0 3 0 4 2 3 0 3 2 1 2 0 1 7 0 1 (6marks)
4. List free space management technique with the help of neat diagram, explain any one
technique in detail. (6marks)

❖ Summer 2024
1. Define following terms: i. Memory compaction ii. Fragmentation(2marks)
2. Describe variable partitioning with the help of suitable example (4marks)
3. Consider the string: 0, 1, 2, 3, 0, 1, 2, 3, 0, 1, 2, 3, 4, 5, 6, 7 with frame size 3 and 4, calculate
page fault in both the cases using FIFO algorithm (6marks)
4. Explain bit map vector and linked list free space management techniques with its
advantages and disadvantages (6marks)

Diploma Helper. Feel free to join us at. 8698079745

You might also like