Operating Systems Memory and Disk Management Comprehensive Study Guide
Examination Logistics, Guidelines, and Academic Integrity
Course and Exam Identification: CS 4760 Operating Systems Test 3, Fall 2025. The examination covers critical memory management and disk storage concepts and accounts for a total of 57 points ().
Mandatory Requirements and Penalties: - Identification: Students are required to write their names on the exam. Failure to do so results in a mandatory loss of five points (). - Calculations and Work: All calculations and rough work must be performed on the reverse (back side) of the test pages. - Legibility Requirement: All written answers must be legible. If the instructor cannot read the script, a zero () will be awarded for that response.
Permitted and Prohibited Items: - This is a closed-book examination. - Permitted: A single notesheet is allowed for reference. - Prohibited: Logging into computer systems during the test is strictly forbidden. The use of any electronic or communications device is prohibited. - Cell Phones: All mobile devices must be placed in silent mode.
Prepaging and Performance in Virtual Memory and Paging Systems
Concept of Prepaging: - Prepaging refers to the strategy of bringing some of a process's pages into main memory before they are explicitly requested by the process. - Benefits/Why it might be a good idea: The primary advantage is the reduction of page faults during the initial execution of a process. If the operating system can accurately predict which pages will be needed (leveraging the principle of locality), it can fetch them in a single batch, which is more efficient than individual disk I/O operations. - Drawbacks/Why not: If the pages brought into memory are not actually used, memory and I/O bandwidth are wasted. This overhead can degrade system performance if the prediction of page usage is inaccurate.
Impact of Random Memory Access Patterns: - Suppose a process is written so poorly that memory requests are purely random, showing no correlation with previous requests. - Effect on Memory Performance: This scenario eliminates the "Locality of Reference" (both temporal and spatial). In such a paging system using virtual memory, performance would plummet, likely leading to "Thrashing." - Explanation: Since there is no pattern, the OS cannot effectively keep a "working set" of pages in memory. Almost every memory request would result in a page fault because the probability of the next random address being in the current frames is extremely low. The system would spend more time swapping pages in and out of disk than executing the process.
Paging Memory Management: Address Translation and Fragmentation
Physical Frame and Address Parameters: - The machine has a total of frames. - Frame Size: (written as ) bytes. - Offset size: bits (derived from bytes).
Free-Frame List (in Hexadecimal): - The available frames are:
0x24,0x2F,0x7A,0x7A,0xA5,0xAD,0x6A,0x8D,0xF3,0x9F,0xA4, and0x0A.Page Table Construction for 10-Frame Process: - Logical Page $\rightarrow$ Physical Frame
0x24- Logical Page $\rightarrow$ Physical Frame0x2F- Logical Page $\rightarrow$ Physical Frame0x7A- Logical Page $\rightarrow$ Physical Frame0x7A- Logical Page $\rightarrow$ Physical Frame0xA5- Logical Page $\rightarrow$ Physical Frame0xAD- Logical Page $\rightarrow$ Physical Frame0x6A- Logical Page $\rightarrow$ Physical Frame0x8D- Logical Page $\rightarrow$ Physical Frame0xF3- Logical Page $\rightarrow$ Physical Frame0x9FAddress Translation Examples: - Logical Address
0x3C1E: - Split address (3 hex digits for offset): Page is0x3, Offset is0xC1E. - Consultation of Page Table: Page maps to Frame0x7A. - Physical Address:0x7AC1E. - Logical Address0x6E4C: - Split address: Page is0x6, Offset is0xE4C. - Consultation of Page Table: Page maps to Frame0x6A. - Physical Address:0x6AE4C.Internal Fragmentation Comparison: - Both paging and fixed partitioning suffer from internal fragmentation. - Fixed Partitioning: This is a major problem because partitions are often large and mismatched to the process size, leading to significant wasted space in every partition that is not perfectly filled. - Paging: This is not considered a major problem because the maximum amount of memory wasted per process is always less than one single page (specifically, the last page of the process). With small, uniform page sizes, this waste is negligible compared to the overhead and flexibility benefits of the system.
Memory Management Simulation: First-Fit System
Initial State: A single block of located at address .
Processing Requests: 1. Time 3: Request for (Burst: ). Address: to . - Blocks left: 1 free block at address with size . 2. Time 6: Request for (Burst: ). Fits in the residue at address . - Blocks left: 1 free block at address with size . 3. Time 6: Request for (Burst: ). Does not fit in remaining . Must wait. 4. Time 10: The process (started at Time 6) finishes. Memory from to is released. 5. Time 13: The process (started at Time 3) finishes. Memory from to is released. 6. Time 13: Request for (Burst: ). 7. Time 20: Request for (Burst: ). 8. Time 24: Request for (Burst: ).
Snapshots of Memory Blocks: - Time 3: block remaining; Size: ; Address: . - Time 9: block remaining; Size: ; Address: . - Time 18: (Analysis required based on First-Fit logic and merges). - Time 25: (Analysis required based on First-Fit logic and merges).
Page Replacement Policy Analysis
Page Request Stream:
0 3 4 2 3 1 2 5 6 3 4System Constraints: available frames. No prepaging assumed.
Policies Tested: - (a) OPT (Optimal): Replaces the page that will not be used for the longest period of time in the future. Requires future knowledge of the stream. - (b) LRU (Least Recently Used): Replaces the page that has not been referenced for the longest period of time. - (c) SECOND-CHANCE/CLOCK: An approximation of LRU using a reference bit. A circular buffer with a pointer ("hand") scans pages; if the reference bit is , it is cleared and the hand moves on. If it is , that page is replaced.
Disk Storage and Inode Structural Theory
Physical Disk Specifications: - Disk Block Size: (written as ) bytes. - Total Disk Capacity: (written as ) bytes.
Drive Metrics: - Total Block Count: blocks ( blocks). - Block Pointer Size: To address blocks, the pointer requires at least bits. In practice, this would likely be stored as a -byte (-bit) pointer.
Inode File System Structure: - Scheme: 12 direct blocks, 1 single indirect block, and 1 double indirect block (similar to BDS/Berkeley Fast File System but lacking triple indirect pointers). - Maximum Theoretical File Size Calculation: - Direct blocks: . - Single Indirect: If pointers are bytes, a block holds pointers. . - Double Indirect: . - Sum total provides the theoretical max file size.
Translation Lookaside Buffer (TLB)
Necessity for Efficiency: - Without a TLB, every logical memory access would require at least two physical memory accesses: one to look up the entry in the page table (stored in main memory) and one to access the actual data. This would halve the effective memory speed. - The TLB functions as a high-speed associative cache that performs the translation in a single hardware cycle, significantly reducing effective access time.
TLB Contents: - The TLB contains a small footprint of the page table. - Each entry typically consists of a Tag (the Virtual Page Number) and a Value (the corresponding Physical Frame Number/Frame address). - It also contains management bits such as the valid bit, dirty bit, and protection bits (read/write/execute).