๐ŸŽ“ BookMCQ
โ† Back to 8. Main Memory

๐Ÿ“ Memory allocation in contiguous memory allocation (14 MCQs)

๐Ÿ“– From Operating System โ€ข 8. Main Memory โ€ข 14 questions available

What is Memory allocation in contiguous memory allocation?

Definition:
Contiguous allocation assigns each process a single continuous segment of memory using strategies like first-fit, best-fit, or worst-fit to manage free holes.

Example:
For a request of size S=40ย KBS = 40 \text{ KB}, best-fit selects the smallest free hole Hโ‰ฅSH \geq S minimizing wasted space compared to first-fit.

Reason:
Simple implementation and fast access due to locality but suffers from external fragmentation limiting long-term memory utilization efficiency.

3
Easy
6
Medium
5
Hard

๐Ÿ“ All Memory allocation in contiguous memory allocation MCQs

Q1. What does the base register store in a protected memory system?

A.The smallest legal physical address โœ…
B.The largest legal physical address
C.The size of the memory segment
D.A flag indicating user mode
๐Ÿ’ก Difficulty: easy | โœ… Correct: A

๐Ÿ“– Explanation: The base register holds the lowest physical address a process may reference, establishing the start of its allowed region. This ensures the CPU cannot address memory below that point. Options B, C, and D describe unrelated concepts: the largest address is defined by the limit, the segment size is the limit value, and privilege flags are stored elsewhere. By keeping the base correct, the system enforces isolation and prevents accidental or malicious access to other memory areas.

Q2. Why is a limit register needed alongside a base register?

A.To store the process priority
B.To define the upper bound of the process's address space โœ…
C.To hold CPU flags
D.To indicate user mode
๐Ÿ’ก Difficulty: easy | โœ… Correct: B

๐Ÿ“– Explanation: The limit register specifies how far beyond the base address a process may go, effectively setting the maximum legal address. Without it, the CPU would have no way to know where the process's memory region ends, risking overlap with other processes. Options A, C, and D describe unrelated functions: priorities are managed by the scheduler, flags are part of status registers, and mode indication is handled by separate control bits.

Q3. If a process has a base register value of 300040 and a limit register value of 120900, what is the highest physical address the process may legally access?

A.420938 โœ…
B.420940
C.420939
D.421000
๐Ÿ’ก Difficulty: easy | โœ… Correct: A

๐Ÿ“– Explanation: The highest address equals base plus limit minus one: 300040+120900โˆ’1=420939300040 + 120900 - 1 = 420939. This calculation defines the inclusive upper bound of the process's address space. Option A is off by one low, Option B exceeds the limit by one, and Option D is far beyond the allowed range. Understanding this arithmetic is crucial for ensuring a process cannot read or write outside its allocated region, which could corrupt other processes or the operating system.

Q4. A user program attempts to read address 421000 with base 300040 and limit 120900. What hardware response is most likely?

A.Translate to a kernel address
B.Silently wrap around to the start of the segment โœ…
C.Ignore the limit and allow the access
D.Raise a protection fault
๐Ÿ’ก Difficulty: medium | โœ… Correct: B

๐Ÿ“– Explanation: The CPU compares the requested address with the base and limit; because 421000 exceeds 300040+120900โˆ’1=420939300040 + 120900 - 1 = 420939, the check fails and the hardware raises a protection fault, terminating or trapping the process. Options A and C describe behaviors that would break isolation, while Option B would mask the error and lead to unpredictable results. The fault mechanism preserves system stability by preventing illegal memory accesses.

Q5. How do base and limit registers relate to the concept of virtual memory?

A.They provide a simple contiguous mapping similar to a segment
B.They eliminate the need for page tables
C.They are used only for kernel memory โœ…
D.They replace the need for address translation hardware
๐Ÿ’ก Difficulty: medium | โœ… Correct: C

๐Ÿ“– Explanation: Base and limit registers implement a basic form of address translation by mapping a contiguous virtual region to a physical region, much like a single segment in segmented memory. This is a precursor to full virtual memory systems, which use more complex structures such as page tables. Options B and D incorrectly claim they remove translation mechanisms, and Option C misstates their scope to kernel memory only.

Q6. Why is memory protection typically enforced by hardware rather than by the operating system?

A.Because the OS cannot access memory at all
B.Because hardware checks are faster than OS checks
C.Because hardware can modify program code โœ…
D.Because the OS lacks necessary privileges
๐Ÿ’ก Difficulty: medium | โœ… Correct: C

๐Ÿ“– Explanation: Hardware can perform address checks on every memory reference with minimal latency, avoiding the performance penalty of a software trap for each access. An OSโ€‘level check would require context switches and additional instructions, dramatically slowing execution. Options A and D misrepresent OS capabilities, and Option C describes a function not related to protection. Fast hardware enforcement thus keeps programs running efficiently while still maintaining strict isolation.

Q7. Given a base register of 200000 and a limit register of 50000, what physical address corresponds to logical address 12345?

A.212300
B.212340
C.212345 โœ…
D.212350
๐Ÿ’ก Difficulty: medium | โœ… Correct: C

๐Ÿ“– Explanation: Physical addresses are calculated by adding the logical offset to the base: 200000+12345=212345200000 + 12345 = 212345. This simple addition respects the limit because 12345 is less than 50000, so the address is valid. Options A, B, and D are close but incorrect arithmetic results, illustrating common offโ€‘byโ€‘few errors. Correct translation is essential for a process to locate its data correctly within the allocated physical memory region.

Q8. Process X has base 100000 and limit 40000. Process Y has base 130000 and limit 30000. Which statement is true?

A.Their address spaces are disjoint
B.Y is fully contained within X's space
C.X is fully contained within Y's space
D.Their address spaces overlap โœ…
๐Ÿ’ก Difficulty: medium | โœ… Correct: D

๐Ÿ“– Explanation: Process X occupies 100000โ€‘139999, while Process Y occupies 130000โ€‘159999, creating an overlapping region from 130000โ€‘139999. Therefore their spaces are not disjoint, and neither process fully contains the other. Options A, B, and C each mischaracterize the relationship, ignoring the shared interval. Overlap would allow one process to read or modify the other's data, violating protection guarantees.

Q9. If a processโ€™s limit register is set to a value smaller than the actual size of its code segment, what is the most likely outcome?

A.The program crashes when accessing code beyond the limit
B.The operating system automatically expands the limit โœ…
C.The CPU ignores the limit and continues execution
D.The process receives extra memory from the system
๐Ÿ’ก Difficulty: medium | โœ… Correct: B

๐Ÿ“– Explanation: When the process tries to execute instructions located beyond the defined limit, the hardware detects the violation and raises a protection fault, typically terminating the program. The OS does not silently adjust limits (Option B), and the CPU does not disregard the limit (Option C). Option D is unrealistic because memory allocation is not dynamic based on faults. This scenario highlights the importance of correctly configuring limit values during loading.

Q10. Which statement best compares base/limit protection with paging?

A.Base/limit provides variableโ€‘sized segments while paging uses fixedโ€‘size pages โœ…
B.Base/limit and paging are functionally identical
C.Paging eliminates the need for limit registers
D.Base/limit can protect multiple processes with a single register set
๐Ÿ’ก Difficulty: hard | โœ… Correct: A

๐Ÿ“– Explanation: The accurate comparison is that base/limit protection offers a simple contiguous segment, whereas paging breaks memory into fixedโ€‘size pages and uses page tables for translation. Option A reverses the correct description, Option C incorrectly claims paging removes limits, and Option D misstates the capability of a single register set to handle many processes. Recognizing these differences clarifies why modern systems favor paging for flexibility despite added complexity.

Q11. A system mistakenly loads a limit register with value 0xFFFFFFFF for a user process. Which mitigation technique would prevent the process from corrupting the kernel?

A.Use a separate privilege level check โœ…
B.Enable address space layout randomization
C.Require the OS to validate limit values before loading
D.Implement a guard page beyond the limit
๐Ÿ’ก Difficulty: hard | โœ… Correct: A

๐Ÿ“– Explanation: Validating limit values before they are programmed into the hardware ensures that absurdly large limits, like 0xFFFFFFFF, are rejected, preserving kernel integrity. A privilege check (Option A) controls access but does not catch malformed limits, ASLR (Option B) randomizes addresses but does not enforce size constraints, and guard pages (Option D) protect against overrun but assume the limit is already reasonable. Proper validation is the primary defense against such configuration errors.

Q12. What is the primary performance penalty associated with hardware address checks using base and limit registers on every memory reference?

A.Increased cache size
B.Longer instruction decode time
C.Need for context switches โœ…
D.Additional comparison per access
๐Ÿ’ก Difficulty: hard | โœ… Correct: C

๐Ÿ“– Explanation: Each memory reference triggers a comparison of the generated address against the base and limit registers, adding a small but measurable delay to every load or store operation. Options A and B describe unrelated hardware characteristics, while Option C pertains to multitasking overhead, not perโ€‘access checks. Understanding this cost helps architects balance security with speed, especially in highโ€‘throughput systems where many memory accesses occur.

Q13. Three processes have the following base and limit values: P1 (base 0, limit 50000), P2 (base 45000, limit 30000), P3 (base 80000, limit 20000). What is the total amount of physical memory occupied and does any overlap occur?

A.95000 bytes with overlap
B.100000 bytes without overlap
C.95000 bytes without overlap โœ…
D.100000 bytes with overlap
๐Ÿ’ก Difficulty: hard | โœ… Correct: C

๐Ÿ“– Explanation: P1 occupies 0โ€‘49999, P2 occupies 45000โ€‘74999, and P3 occupies 80000โ€‘99999. The overlap between P1 and P2 (45000โ€‘49999) is 5000 bytes. Unique memory used = 50000 (P1) + 30000 (P2) โ€“ 5000 (overlap) + 20000 (P3) = 95000 bytes, and overlap is present. Options B and D give incorrect totals, and Option C incorrectly states there is no overlap. This calculation demonstrates how overlapping segments waste memory and violate protection rules.

Q14. Which tradeโ€‘off best describes the use of base/limit registers versus more complex segmentation schemes in modern operating systems?

A.Base/limit requires more hardware support than segmentation
B.Base/limit is simpler and faster but less flexible
C.Segmentation provides better security at the cost of speed โœ…
D.Segmentation eliminates the need for paging
๐Ÿ’ก Difficulty: hard | โœ… Correct: C

๐Ÿ“– Explanation: Base and limit registers give a straightforward, lowโ€‘overhead way to delineate a processโ€™s address space, making address checks fast but limiting the ability to create multiple, variableโ€‘size segments. Segmentation offers greater flexibility by allowing several segments with different attributes, but it introduces extra hardware and software complexity. Options A and D misrepresent the hardware requirements, and Option C reverses the typical securityโ€‘performance relationship. Recognizing this tradeโ€‘off helps designers choose the appropriate protection mechanism for their system goals.

๐Ÿ”— Related Topics (MCQs)