Operating Systems · Unit 4 · 8 hrs
Memory Management
Exam-focused notes for Memory Management (Operating Systems, CSC264): what the TU syllabus asks and how it has actually been tested, with 18 solved past questions from this unit.
What this unit covers
- Introduction
- Monoprogramming vs. Multi-programming
- Modelling Multiprogramming
- Multiprogramming with fixed and variable partitions
- Relocation and Protection
- Memory management (Bitmaps & Linked-list)
- Memory Allocation Strategies
- Virtual memory: Paging, Page Table, Page Table Structure, Handling Page Faults, TLB's
- Page Replacement Algorithms: FIFO, Second Chance, LRU, Optimal, LFU, Clock, WS-Clock
- Concept of Locality of Reference
- Belady's Anomaly
- Segmentation: Need of Segmentation, its Drawbacks, Segmentation with Paging(MULTICS)
Segmentation
Explain the translation of logical address into physical address using segment table with necessary diagram. List advantages and disadvantages of segmentation.[10]
Segmentation is a memory management technique in which memory is divided into variable size parts. Each part is known as a segment, which can be allocated to a process. The details about each segment are stored in a table called the segment table. --- The s...
Full solved answer →Differentiate between paging and segmentation. [5]
Paging and segmentation are both memory management techniques used by operating systems, but they differ in several important ways. --- Basis Paging Segmentation --------- Block Size Page is always of fixed block size. Segment is of variable block size. Fra...
Full solved answer →Memory Allocation Strategies
Consider a swapping system in which memory consists of the following hole sizes in memory order: 15 MB, 2 MB, 10 MB, 6 MB, 8 MB and 20 MB. Which hole is taken for successive segment requests of: (a) 10 MB (b) 10 MB For first fit, next fit and best fit. [5]
Holes in memory order: Hole Size -------------- 1 15 MB 2 2 MB 3 10 MB 4 6 MB 5 8 MB 6 20 MB Successive requests: (a) 10 MB, (b) 10 MB. Allocates the first hole large enough, scanning from the start each time. (a) 10 MB: Hole 1 (15 MB) $\ge 10$ → allocate. ...
Full solved answer →Explain different memory allocation strategies. [5]
Memory allocation strategies are methods used by the process manager to allocate free memory partitions (holes) to processes. The main strategies are described below: --- The process manager scans the list of segments from the beginning and allocates the fi...
Full solved answer →Differentiate between internal and external fragmentation? Suppose that we have memory of 100 KB with 5 partitions of size 150 KB, 200 KB, 250 KB, 100 KB, and 300 KB. Where the processes A and B of size 175 KB and 125 KB will be loaded, if we used Best-Fit, and Worst-Fit Strategy? [5]
Aspect Internal Fragmentation External Fragmentation --------- Definition Wasted memory inside an allocated partition when the process is smaller than the block assigned to it Total free memory is enough, but it is split into scattered non-contiguous holes,...
Full solved answer →Virtual memory
Write short notes on: a. Virtual Memory b. Race Condition [5]
--- Virtual Memory is a memory management technique in which the operating system uses a portion of the hard disk as an extension of RAM, thereby increasing the effective size of usable memory beyond the physical RAM available. - When the kernel needs memor...
Full solved answer →When does a page fault occur? Give a structure of a page table. [5]
A page fault occurs when a program attempts to access data or code that is in its address space, but is not currently located in the system RAM (i.e., the required page is not present in physical memory). When a page fault occurs, the following sequence of ...
Full solved answer →Write the structure and advantages of TLB. [5]
--- TLB is a special high-speed hardware cache (associative memory) used to speed up virtual-to-physical address translation in a paging system. It stores recently used page table entries to avoid repeated access to the main memory page table. --- TLB is or...
Full solved answer →Why do we need virtual memory? Describe the structure of a page table. [5]
--- Virtual memory is a memory management technique that allows a computer to execute programs that are larger than the available physical (main) memory. The key reasons we need virtual memory are: 1. Running large programs: A process does not need to be fu...
Full solved answer →Belady's Anomaly
What does Belady's anomaly mean? What are the benefits of multiprogramming over uniprogramming? [5]
--- Belady's anomaly is the phenomenon in which increasing the number of page frames results in an increase in the number of page faults for certain memory access patterns. This is a counter-intuitive behavior because logically, more frames should mean more...
Full solved answer →Page Replacement Algorithms
Consider the page references 7,0,1,2,0,3,0,4,2,3,0,3,2. Find the number of page fault using OPR and FIFO, with 4 page frame. [5]
- Reference string: 7, 0, 1, 2, 0, 3, 0, 4, 2, 3, 0, 3, 2 (13 references) - Number of frames: 4 --- Replace the page not needed for the longest time in the future. Ref Frames Fault? --------------------- 7 7 F 0 7,0 F 1 7,0,1 F 2 7,0,1,2 F 0 7,0,1,2 Hit 3 r...
Full solved answer →Why OPR is best but not practically feasible page replacement algorithm? Calculate the number of page faults for OPR, LRU and Clock page replacement algorithm for the reference string: 1, 3, 4, 2, 3, 5, 4, 3, 1, 2, 4, 6, 3, 2, 1, 4, 2. Assume the memory size is 3.[10]
- Reference String: 1, 3, 4, 2, 3, 5, 4, 3, 1, 2, 4, 6, 3, 2, 1, 4, 2 - Number of Frames: 3 --- Optimal Page Replacement (OPR) replaces the page that will not be used for the longest period of time in the future. Why BEST: - Yields the minimum possible page...
Full solved answer →How Second Chance page replacement algorithm differs from FIFO page replacement policy? Discuss the concept of Belady’s anomaly with suitable example.[10]
--- In FIFO (First-In-First-Out) page replacement, the page that has been in memory the longest is replaced first, regardless of how frequently or recently it has been used. Key characteristics of FIFO: - Pages are maintained in a queue; the oldest page (fr...
Full solved answer →Find the number of page fault using FIFO and LRU for the reference string 4, 7, 6, 1, 7, 6, 1, 2, 7, 2 with frame size 3. [5]
- Reference string: 4, 7, 6, 1, 7, 6, 1, 2, 7, 2 - Number of frames: 3 --- Replace the oldest loaded page when frames are full. Ref Frame contents (oldest→newest) Fault? -------------------------------------------- 4 4 Fault 7 4, 7 Fault 6 4, 7, 6 Fault 1 7...
Full solved answer →Define working set. How does clock replacement algorithm works? [5]
--- The working set of a process is the set of pages that a process is currently using (actively referencing) within a defined time window. Formally, the working set W(t, Δ) is defined as: W(t, Δ) = the set of pages referenced by a process during the time i...
Full solved answer →Concept of Locality of Reference
Why do we need the concept of locality of reference? List the advantages and disadvantages of Round Robin algorithm. [5]
--- Locality of Reference refers to the tendency of a processor to access the same set of memory locations repetitively over a short period of time. It is the basis for the design of cache memory and virtual memory systems. 1. Basis for Virtual Memory: Virt...
Full solved answer →Monoprogramming vs. Multi-programming
Differentiate between multi programming and Monoprogramming. What will be the CPU utilization with 6 processes with 60% IO waiting time are in memory? [5]
- Number of processes: $n = 6$ - I/O wait fraction: $p = 60\% = 0.60$ --- Feature Monoprogramming Multiprogramming --------- Definition Only one program resides and executes in memory at a time Several programs reside in memory simultaneously and the CPU sw...
Full solved answer →Relocation and Protection
Why program relocation and protection is important? Explain the technique of achieving program relocation and protection. [5]
Program Relocation is important because: - In a multiprogramming environment, multiple processes must reside in memory simultaneously. A program cannot always be loaded at the same fixed memory address, so it must be relocated to whatever memory space is av...
Full solved answer →Make Unit 4 stick
Practice CSC264 with flashcards & quizzes