Unit 05 OSY (22516)
Unit 05 OSY (22516)
• 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
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
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.
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.
1. The list starts with a pointer to the first free block in memory.
3. When a block is allocated or freed, the list is updated to reflect changes in available
memory
iii) Diagram
iv) Advantages
o Easily adapted for variable-sized memory blocks, as each node can represent blocks of
different sizes.
v) Disadvantages
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.
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.
❖ 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
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.
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.
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.
❖ 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
• 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.
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.
2. Segment Table Overhead: Each process requires a segment table, increasing memory
usage and complexity.
❖ Paging vs Segmentation
❖ 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
❖ 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
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.
1. First-Come , First-Served(FCFS)
• 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.
❖ 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)
❖ 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)