πŸŽ“ BookMCQ
← Back to 1. Introduction to Operating System

πŸ“ Introduction to Memory Management in Operating Systems (30 MCQs)

Memory Management and Process Address Spaces

Memory management controls the allocation, organization, protection, and reclamation of main memory during program execution. The memory manager coordinates physical RAM with process address spaces, translating logical or virtual addresses into physical locations. It allows multiple processes to occupy memory safely, supports controlled sharing, and provides abstractions that separate application memory references from the actual arrangement of hardware memory.

Why Physical Memory Requires Allocation and Protection

Main memory has limited capacity, while processes require different amounts of code, data, and temporary storage. Direct physical addressing can create conflicts when several programs run concurrently or when a process accesses another process's data. Relocation, address translation, and protection mechanisms solve these problems. Virtual memory further allows applications to use address spaces larger than their currently resident physical-memory allocations.

Address Translation, Paging, and Memory Allocation

The memory management unit (MMU) translates virtual addresses into physical addresses using hardware-supported mapping information maintained by the operating system. In paging, virtual memory is divided into fixed-size pages and physical memory into equal-size frames. Page tables record mappings, while a translation lookaside buffer (TLB) caches recent translations to accelerate address resolution.

Translating a Virtual Address into a Physical Frame

Consider a system with 4 KiB pages and a process referencing virtual address 8,500. Dividing by 4,096 gives virtual page number 2 and offset 308. If the page table maps virtual page 2 to physical frame 7, the physical address is 7 multiplied by 4,096 plus 308, producing 29,000.

Virtual Memory Benefits, Fragmentation, and Performance

Memory management enables isolation, controlled sharing, relocation, and efficient RAM utilisation. Paging avoids external fragmentation in physical frame allocation but can produce internal fragmentation in the final allocated page. Page faults and excessive swapping can severely reduce performance, while large page tables and TLB misses introduce additional costs. Memory-intensive applications depend heavily on effective allocation and translation.

Misconceptions About Pages and Physical Memory

'A virtual address is always a physical address' is incorrect because the MMU translates it through mapping structures. 'Paging completely eliminates fragmentation' is incorrect because internal fragmentation remains possible. 'A page fault always indicates an invalid address' is incorrect because a valid page may simply be absent from RAM and require loading.

Exam Focus: Paging, Address Translation, and Page Faults

Practise calculating page numbers, offsets, and physical addresses using the specified page size and frame mapping. Be able to trace page-table lookups, explain TLB hits and misses, and distinguish valid page faults from protection violations. Questions may compare paging with segmentation and test internal fragmentation, virtual memory, allocation, and the effects of excessive page faults.

Key Terms of Memory Management

  • Virtual address - Address generated by a process.
  • Physical address - Actual main-memory location.
  • Page - Fixed-size virtual memory block.
  • Frame - Fixed-size physical memory block.
  • MMU - Hardware performing address translation.
  • TLB - Cache for recent address translations.
10
Easy
10
Medium
10
Hard

πŸ“ All Introduction to Memory Management in Operating Systems MCQs

Q1. A program running in user mode computes address 2450 before accessing an array. Which component translates this address into the corresponding location in main memory?

A.CPU scheduler
B.Memory Management Unit βœ…
C.Device controller
D.Process dispatcher
πŸ’‘ Difficulty: easy | βœ… Correct: B

πŸ“– Explanation: The CPU normally generates logical addresses, while the memory-management unit translates them into physical addresses before memory access. The tempting physical-address option reverses the roles of the processor and translation hardware.

Q2. A memory-management system uses a base register of 18000 and a limit register of 1000. A process generates logical address 740. What physical address will the hardware generate?

A.19000
B.18000
C.18740 βœ…
D.18739
πŸ’‘ Difficulty: easy | βœ… Correct: C

πŸ“– Explanation: Relocation adds the logical offset to the base register after checking the limit. Thus 18000+740=1874018000+740=18740. The tempting value 19000 incorrectly adds the limit instead of the requested offset value itself.

Q3. A process has base address 5000 and limit 800. Which logical offset is valid for this process?

A.799 βœ…
B.800
C.801
D.1200
πŸ’‘ Difficulty: easy | βœ… Correct: A

πŸ“– Explanation: A limit of 800 permits offsets from 0 through 799. Offset 799 is therefore valid, while 800 is outside the process's allocated range; the tempting boundary value is not included.

Q4. A software manufacturer develops a program for a dedicated computer whose memory location is known before compilation. Which address-binding method is most appropriate?

A.Execution-time binding
B.Dynamic relocation
C.Load-time binding
D.Compile-time binding βœ…
πŸ’‘ Difficulty: easy | βœ… Correct: D

πŸ“– Explanation: Compile-time binding is possible when the program's physical starting location is known before compilation. Changing that location later requires recompilation; the tempting run-time option applies when translation is deferred until execution.

Q5. A multiprogrammed server temporarily transfers an entire inactive process memory image from RAM to secondary storage to free memory for another application. Which memory-management operation is being performed?

A.Compaction
B.Swapping βœ…
C.Paging
D.Segmentation
πŸ’‘ Difficulty: easy | βœ… Correct: B

πŸ“– Explanation: Swapping moves a process's memory image between main memory and backing storage, freeing RAM for other work. The tempting paging option transfers individual pages rather than moving the entire process image.

Q6. An operating system uses variable-sized contiguous memory allocation. Several applications finish execution, leaving separated free regions whose combined size is sufficient for a new application, but no individual region is large enough. What problem exists?

A.Internal fragmentation
B.Page-table fragmentation
C.External fragmentation βœ…
D.Working-set fragmentation
πŸ’‘ Difficulty: easy | βœ… Correct: C

πŸ“– Explanation: External fragmentation occurs when free memory is split into separated holes, so total free space can exceed the largest available block. The tempting internal-fragmentation option describes wasted space inside an allocated region.

Q7. A system uses paging with equal-sized pages and frames. A process occupies 10 pages, but its final page contains only 300 bytes of useful data. Which statement correctly describes the fragmentation?

A.External fragmentation is eliminated, but internal fragmentation may occur βœ…
B.Both internal and external fragmentation are completely eliminated
C.Only external fragmentation occurs inside the final page
D.Paging necessarily creates one large external hole
πŸ’‘ Difficulty: easy | βœ… Correct: A

πŸ“– Explanation: Paging allocates equal-sized pages into equal-sized frames, avoiding external fragmentation. A partially filled final page can still waste space internally; the tempting claim that paging eliminates all fragmentation is too strong.

Q8. A computer uses 16-bit logical addresses and a page size of 1 KiB. How many bits are required for the page number?

A.10 bits
B.12 bits
C.4 bits
D.6 bits βœ…
πŸ’‘ Difficulty: easy | βœ… Correct: D

πŸ“– Explanation: A 1 KiB page needs 10 offset bits because 1textKiB=2101\\text{ KiB}=2^{10} bytes. The remaining 16βˆ’10=616-10=6 bits identify the page; the tempting 10-bit page number reverses these fields for this address.

Q9. A system has a 32-bit logical address space, a page size of 4 KiB, and four-byte page-table entries. Assuming a single-level page table covering the entire address space, what is its size?

A.1 MiB
B.4 MiB βœ…
C.2 MiB
D.8 MiB
πŸ’‘ Difficulty: easy | βœ… Correct: B

πŸ“– Explanation: The address space contains 232/212=2202^{32}/2^{12}=2^{20} virtual pages. Each entry uses four bytes, so the table occupies 220times4=42^{20}\\times4=4 MiB total; the tempting 1 MiB omits entry width for the full address space.

Q10. A process accesses segment 2, whose base is 4000 and limit is 600. What condition must be satisfied before the operating system forms the physical address?

A.The logical offset must equal the segment base
B.The offset must be greater than 600
C.The offset must be smaller than 600 βœ…
D.The offset must always be zero
πŸ’‘ Difficulty: easy | βœ… Correct: C

πŸ“– Explanation: Each segment has a base and limit. The offset must be smaller than its limit before the base is added; the tempting unconditional address calculation ignores bounds checking and could permit access beyond the segment.

Q11. A memory allocator assigns an 18 KiB application to a fixed partition of 24 KiB. How much internal fragmentation results from this allocation?

A.6 KiB βœ…
B.18 KiB
C.24 KiB
D.42 KiB
πŸ’‘ Difficulty: medium | βœ… Correct: A

πŸ“– Explanation: A 24 KiB fixed partition holds an 18 KiB process, leaving 24βˆ’18=624-18=6 KiB unused inside its allocation. That is internal fragmentation; the tempting external label refers to separated free holes.

Q12. A web server maintains free memory holes in the following order: 100 KiB, 500 KiB, 200 KiB, 300 KiB, and 600 KiB. A new application requires 212 KiB. Using first-fit allocation, which hole is selected and how much remains?

A.300 KiB hole, with 88 KiB remaining
B.500 KiB hole, with 288 KiB remaining βœ…
C.600 KiB hole, with 388 KiB remaining
D.200 KiB hole, with -12 KiB remaining
πŸ’‘ Difficulty: medium | βœ… Correct: B

πŸ“– Explanation: First fit scans holes in their listed order and selects the first one large enough. The 100 KiB hole fails, but the 500 KiB hole fits 212 KiB, leaving 288 KiB.

Q13. A process generates logical address 2500 with a page size of 1024 bytes. Its page table maps page 2 to frame 7. A student incorrectly uses 2500 as the page offset. What is the correct physical address?

A.7620
B.7200
C.7624
D.2500 βœ…
πŸ’‘ Difficulty: medium | βœ… Correct: D

πŸ“– Explanation: Divide the logical address by the 1024-byte page size: page \\\lfloor2500/1024\\rfloor=2\, offset \2500-2048=452\. Frame 7 gives \7\\times1024+452=7620\; the tempting offset 2500 is not normalized correctly during this translation and frame lookup.

Q14. A processor uses a TLB with a hit ratio of 80%. TLB lookup takes 10 ns, and memory access takes 100 ns. A miss requires one page-table access followed by one data access. What is the effective access time?

A.110 ns
B.120 ns
C.130 ns βœ…
D.210 ns
πŸ’‘ Difficulty: medium | βœ… Correct: C

πŸ“– Explanation: A TLB hit costs \10+100=110\ ns; a miss costs \10+100+100=210\ ns. Therefore \0.8(110)+0.2(210)=130\ ns. The tempting 120 ns omits one memory access on a miss.

Q15. A computer uses a 32-bit virtual address, 4 KiB pages, and four-byte entries in a two-level page table. Each second-level table contains 1024 entries. If the virtual page number is divided equally between both levels, how many bits identify each page-table index?

A.10 bits βœ…
B.12 bits
C.20 bits
D.8 bits
πŸ’‘ Difficulty: medium | βœ… Correct: A

πŸ“– Explanation: A 4 KiB page leaves 12 offset bits. Each 4-byte entry table holds \4096/4=1024=2^{10}\ entries, so the remaining 20 virtual-page bits split into two 10-bit indexes for lookup.

Q16. A database application shares a memory segment with another process. The segment is marked read-only in its protection information. What happens when the application attempts to modify that segment?

A.The processor silently accepts the modification
B.A protection exception occurs and control transfers to the operating system βœ…
C.The operating system automatically enlarges the segment
D.The application receives a new physical frame without checking permissions
πŸ’‘ Difficulty: medium | βœ… Correct: B

πŸ“– Explanation: A write to a read-only segment violates its protection attributes, so hardware traps to the operating system. The tempting permission assumption is wrong because a valid address does not imply permission to write.

Q17. A variable-sized contiguous allocator contains several separated free holes. Their combined capacity is 900 KiB, but the largest individual hole is 300 KiB. A process requires 600 KiB of contiguous memory. Which technique can make allocation possible without changing the process size?

A.Increasing the page-table entry size
B.Disabling memory protection
C.Compaction
D.Reducing the process identifier βœ…
πŸ’‘ Difficulty: medium | βœ… Correct: D

πŸ“– Explanation: Compaction moves allocated regions so separated free holes combine into one larger contiguous region. The tempting paging solution changes allocation structure; compaction specifically rearranges movable contiguous allocations when relocation is supported.

Q18. A graphics application contains an optional image-processing routine that users rarely need. The operating system loads that routine into memory only when the user first invokes it. Which technique is being used?

A.Static linking
B.Swapping
C.Dynamic loading βœ…
D.Memory compaction
πŸ’‘ Difficulty: medium | βœ… Correct: C

πŸ“– Explanation: Dynamic loading brings a routine into memory only when execution first needs it, reducing the initial memory footprint. The tempting static-loading approach loads all routines in advance, including unused optional components.

Q19. A memory allocator records available contiguous holes after successive releases: Time 1: (40,30,50) KiB ; Time 2: (20,30,40,30) KiB ; Time 3: (60,20,40) KiB ; Time 4: (50,50,20) KiB ; Time 5: (80,10,30) KiB. An application requests one contiguous 70 KiB block. At which earliest time does external fragmentation prevent allocation despite 120 KiB total free memory?

A.Time 1 βœ…
B.Time 3
C.Time 4
D.Time 5
πŸ’‘ Difficulty: medium | βœ… Correct: A

πŸ“– Explanation: At time 1, total free space is \40+30+50=120\ KiB, but the largest hole is only 50 KiB. A 70 KiB contiguous request fails; later times are not earlier either at that stage.

Q20. A process can be moved to another physical memory location while it is executing, without recompiling its instructions. Which address-binding approach supports this capability?

A.Compile-time binding
B.Static address binding
C.Load-time binding
D.Run-time binding βœ…
πŸ’‘ Difficulty: medium | βœ… Correct: D

πŸ“– Explanation: Run-time binding translates logical addresses during execution, allowing a process to move without recompiling its instructions. The tempting load-time binding fixes addresses when the program is loaded and cannot freely relocate it afterward.

Q21. A demand-paging system has a memory access time of 100 ns, a page-fault probability of 0.0005, and a page-fault service time of 6 ms. Using \EAT=(1-p)m+ps\, what is the approximate effective access time?

A.0.3 microseconds
B.3.1 microseconds βœ…
C.6 microseconds
D.30 microseconds
πŸ’‘ Difficulty: hard | βœ… Correct: B

πŸ“– Explanation: The fault probability is 0.0005. Using \EAT=(1-p)m+ps\, we get \0.9995(100)+0.0005(6,000,000)=3099.95\ ns, or approximately 3.1 microseconds. The tempting 300 ns understates the rare but expensive fault cost rather than normal access alone.

Q22. A database buffer pool has three page frames and uses LRU replacement. Starting with empty frames, it receives the reference string 1, 2, 3, 1, 4, 1, 2, 5, 1, 2, 3, 4. How many page faults occur?

A.6
B.7
C.8 βœ…
D.9
πŸ’‘ Difficulty: hard | βœ… Correct: C

πŸ“– Explanation: LRU faults on references 1, 2, 3, 4, 2, 5, 3, and 4. That totals eight faults; the tempting count of twelve treats every reference as a miss despite repeated resident-page hits.

Q23. A FIFO page-replacement experiment records the following results: (1 frame, 10 faults) ; (2 frames, 8 faults) ; (3 frames, 9 faults) ; (4 frames, 7 faults) ; (5 frames, 6 faults). Which observation demonstrates Belady's anomaly?

A.Faults increase from 8 to 9 when frames increase from 2 to 3 βœ…
B.Faults decrease from 10 to 8 when frames increase from 1 to 2
C.Faults decrease from 9 to 7 when frames increase from 3 to 4
D.Faults decrease from 7 to 6 when frames increase from 4 to 5
πŸ’‘ Difficulty: hard | βœ… Correct: A

πŸ“– Explanation: Faults increase from eight with two frames to nine with three frames, despite adding memory frames. This is Belady's anomaly for FIFO; the tempting four-frame comparison shows a decrease, not the anomaly.

Q24. A virtual-memory system uses a working-set window of five references. At a particular instant, the most recent references are 2, 3, 2, 4, and 5. What is the working-set size?

A.2 pages
B.3 pages
C.5 pages
D.4 pages βœ…
πŸ’‘ Difficulty: hard | βœ… Correct: D

πŸ“– Explanation: The most recent five references contain pages 2, 3, 2, 4, and 5. The distinct set is \\\{2,3,4,5\\}\, so its working-set size is four; repeated page 2 counts once in this window.

Q25. A multiprogrammed system records CPU utilization against the degree of multiprogramming: (1,20%) ; (2,40%) ; (4,70%) ; (8,90%) ; (12,65%). At which tested degree is CPU utilization highest?

A.4 processes
B.8 processes βœ…
C.12 processes
D.2 processes
πŸ’‘ Difficulty: hard | βœ… Correct: B

πŸ“– Explanation: Utilization reaches its highest listed value, 90%, at degree eight, then drops to 65% at twelve. The tempting twelve-process choice assumes more concurrency always helps, ignoring thrashing and resource contention.

Q26. A process accesses segment 2, which has base address 4000 and limit 600. A student calculates the physical address as 4600 for logical offset 600 and declares the access valid. What is the error?

A.The base register should be subtracted from the offset
B.The limit should be added twice
C.The offset equals the limit and therefore causes a protection fault βœ…
D.The segment base must always be zero
πŸ’‘ Difficulty: hard | βœ… Correct: C

πŸ“– Explanation: The flawed step accepts offset 600 because it adds the base immediately. A segment limit of 600 permits only offsets 0 through 599, so this access causes a protection fault.

Q27. A student calculates a single-level page table for a 32-bit virtual address space with 4 KiB pages and four-byte page-table entries as 1 MiB. Which correction is accurate?

A.The table requires 2 MiB because the address space has 21 page bits
B.The table requires 8 MiB because each page has two entries
C.The table requires 1 MiB because each entry uses one byte
D.The table requires 4 MiB because there are \2^{20}\ entries of four bytes each βœ…
πŸ’‘ Difficulty: hard | βœ… Correct: D

πŸ“– Explanation: The flawed calculation counts each page-table entry as one byte. With \2^{20}\ entries and four bytes per entry, the single-level table needs \4\\times2^{20}=4\ MiB; 1 MiB omits entry size, which is the proper correction.

Q28. Two processes use the same virtual page number but map it to different physical frames. Their address spaces use a TLB without address-space identifiers. What must the operating system do during a switch between these processes to prevent stale translations?

A.Flush or invalidate the previous process's TLB entries βœ…
B.Reuse all previous TLB entries without modification
C.Clear all physical memory before scheduling the second process
D.Disable the page table permanently
πŸ’‘ Difficulty: hard | βœ… Correct: A

πŸ“– Explanation: Two processes can use the same virtual page number but map it to different frames. Without ASIDs, the TLB must be flushed or invalidated on switching; the tempting reuse risks stale translations.

Q29. A shared-memory operating system allows several applications to map the same executable code pages into their address spaces. The code pages are read-only, while each process has separate writable data pages. Why is this arrangement safe and memory-efficient?

A.All applications use one shared writable data region
B.Read-only code can be shared, while private data remains independently protected
C.The operating system disables memory protection for executable pages βœ…
D.Each process receives a separate physical copy of every code page
πŸ’‘ Difficulty: hard | βœ… Correct: C

πŸ“– Explanation: Read-only code pages can be mapped into multiple processes because none may modify the shared instructions. Private writable data remains separate; the tempting writable-code arrangement would allow one process to corrupt another's code.

Q30. A system uses two-level paging with 32-bit virtual addresses, 4 KiB pages, and four-byte page-table entries. Each process uses three virtual regions mapped through three distinct first-level entries. Each required second-level table contains 1024 entries. How much memory is needed for the complete page-table hierarchy, including the outer table?

A.12 KiB
B.16 KiB βœ…
C.8 KiB
D.4 MiB
πŸ’‘ Difficulty: hard | βœ… Correct: B

πŸ“– Explanation: The outer table uses \1024\\times4=4\ KiB. Three distinct second-level tables add \3\\times4=12\ KiB, totaling 16 KiB for the process; the tempting 12 KiB omits the outer table for the complete page-table hierarchy.

πŸ”— Related Topics (MCQs)