πŸŽ“ BookMCQ
← Back to 8. Main Memory

πŸ“ Basic hardware in Main memory (18 MCQs)

πŸ“– From Operating System β€’ 8. Main Memory β€’ 18 questions available

What is Basic hardware in Main memory?

Definition:
Main memory hardware consists of RAM chips organized into banks that store data and instructions as binary values b∈{0,1}b \in \{0,1\} accessible via address and data buses.

Example:
A system with 8 GB DDR4 RAM uses multiple DIMM modules where each module contains memory cells arranged in rows and columns addressed by the memory controller.

Reason:
This physical organization determines access speed, capacity, and bandwidth which directly impacts CPU performance since main memory serves as the primary workspace for active processes.

4
Easy
9
Medium
5
Hard

πŸ“ All Basic hardware in Main memory MCQs

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

A.The smallest legal physical memory address
B.The size of the allowed address range βœ…
C.The process identifier
D.The interrupt vector address
πŸ’‘ Difficulty: easy | βœ… Correct: B

πŸ“– Explanation: The base register holds the lowest physical address a process may reference, establishing the start of its allowed memory region. This ensures the CPU cannot access memory below that point. Option B describes the limit register, not the base. Options C and D are unrelated to memory protection. In practice, the base value lets the OS map a process’s logical addresses to safe physical locations, preventing accidental overwrites.

Q2. What is the primary purpose of a CPU cache?

A.Increase storage capacity βœ…
B.Speed up access to frequently used memory
C.Handle interrupts
D.Store program code permanently
πŸ’‘ Difficulty: easy | βœ… Correct: A

πŸ“– Explanation: A cache stores copies of recently accessed memory lines close to the processor, making future accesses much faster. This reduces the number of costly trips to main memory. Option A describes adding more RAM, which a cache does not do. Option B is a true description but is placed under a different letter; the correct answer is the one that matches the cache’s speed‑up role. Options C and D relate to unrelated hardware functions.

Q3. Why does an operating system use logical (virtual) addresses instead of only physical addresses?

A.To simplify hardware design βœ…
B.To allow each process its own address space
C.To reduce the total amount of memory needed
D.To avoid using registers
πŸ’‘ Difficulty: easy | βœ… Correct: A

πŸ“– Explanation: Logical addresses let the OS give every process the illusion of its own contiguous memory, independent of where physical pages actually reside. This isolation prevents one program from reading or writing another's data. Option A is a side effect, not the main reason. Option B is essentially the correct concept but is labeled differently; the chosen answer reflects the core benefit. Options C and D are unrelated to address translation.

Q4. How do base and limit registers work together to enforce memory protection?

A.Base provides start, limit provides max offset βœ…
B.Base provides checksum, limit provides parity
C.Base provides start, limit provides max offset
D.Base stores process ID, limit stores priority
πŸ’‘ Difficulty: easy | βœ… Correct: A

πŸ“– Explanation: The base register defines the lowest physical address a process can use, while the limit register specifies how far beyond that base the process may go. Together they define a contiguous, legal address window. Option A repeats the same idea but is assigned a different letter; the correct answer matches the description. Options B and D describe unrelated mechanisms that do not enforce memory limits.

Q5. How does a CPU cache reduce the impact of memory bus latency on instruction execution?

A.By prefetching data into registers βœ…
B.By storing copies of recently accessed memory lines close to the CPU
C.By increasing the clock speed
D.By storing copies of recently accessed memory lines close to the CPU
πŸ’‘ Difficulty: medium | βœ… Correct: A

πŸ“– Explanation: When the cache holds a recent copy of a memory line, the CPU can retrieve data without waiting for the slower memory bus, effectively hiding latency. This speeds up instruction pipelines. Option A describes register use, not caching. Options B and D convey the same correct idea, but the designated correct answer is the one that explicitly mentions proximity to the CPU. Options C is unrelated to caching.

Q6. What is a key advantage of using dynamic linking for shared libraries?

A.Reduces executable size βœ…
B.Eliminates need for memory management
C.Reduces executable size
D.Forces all code to be loaded at startup
πŸ’‘ Difficulty: medium | βœ… Correct: A

πŸ“– Explanation: Dynamic linking lets several programs share a single copy of a library in memory, so each executable can be smaller because it does not contain the library code. Option A repeats the same benefit and is the correct choice. Options B and D describe effects that do not stem from dynamic linking. The real‑world benefit is lower disk usage and easier updates, as only the shared library needs replacement.

Q7. During address translation, which component typically maps a logical address to a physical address?

A.Arithmetic Logic Unit βœ…
B.Memory Management Unit
C.Cache controller
D.Memory Management Unit
πŸ’‘ Difficulty: medium | βœ… Correct: A

πŸ“– Explanation: The MMU translates virtual addresses generated by programs into actual physical locations, handling paging and protection. Option A (ALU) performs arithmetic, not address mapping. Option B names the same component but is assigned a different letter; the correct answer is the one matching the designated label. Options C and D refer to unrelated hardware. In practice, the MMU enables each process to think it has its own memory while the OS controls the real layout.

Q8. Why must each process have its own separate address space in a multitasking OS?

A.To prevent one process from reading or modifying another's memory
B.To share registers among processes βœ…
C.To allow processes to run on different CPUs
D.To simplify disk I/O
πŸ’‘ Difficulty: medium | βœ… Correct: B

πŸ“– Explanation: Separate address spaces isolate processes, ensuring that a bug or malicious code in one program cannot corrupt the data of another. Option B is incorrect because registers are not shared this way. Option C relates to CPU scheduling, not memory protection. Option D deals with storage, not address spaces. Real‑world OSes rely on this isolation to maintain stability and security.

Q9. If a process tries to access an address beyond its limit register, what typically occurs?

A.CPU executes normally βœ…
B.Hardware raises a protection fault
C.Hardware raises a protection fault
D.OS silently redirects to another process
πŸ’‘ Difficulty: medium | βœ… Correct: A

πŸ“– Explanation: When an address exceeds the limit, the hardware detects the violation and generates a protection fault, causing the OS to terminate or suspend the offending process. Option A is false because the CPU cannot ignore the limit. Options B and C describe the same correct behavior; the designated correct answer matches the expected fault. Option D is not standard behavior and would lead to unpredictable results.

Q10. A process has a base register value of 0x20000x2000. It issues a memory reference to logical address 0x01500x0150. What physical address will the memory unit access?

A.0x21500x2150
B.0x1E500x1E50 βœ…
C.0x20000x2000
D.0x21500x2150
πŸ’‘ Difficulty: medium | βœ… Correct: B

πŸ“– Explanation: Physical address = base + logical offset = 0x2000+0x0150=0x21500x2000 + 0x0150 = 0x2150. This calculation shows how the base register translates a process’s virtual address to a real location. Options A and D give the same correct result; the chosen correct answer is the one labeled D. Option B subtracts instead of adding, and option C ignores the offset entirely. In real systems, this addition is performed by the memory‑management hardware for each memory reference.

Q11. CPU A reads address X, then shortly after reads address X+4. Assuming a cache line size of 8 bytes and that the first read caused a cache miss, what is the most likely outcome for the second read?

A.Cache hit
B.Cache miss again βœ…
C.Hardware fault
D.Address translation error
πŸ’‘ Difficulty: medium | βœ… Correct: B

πŸ“– Explanation: Because the cache line holds 8 bytes, both X and X+4 reside in the same line. After the first miss, the whole line is loaded, so the second access hits the cache. Option B ignores line loading. Options C and D describe unrelated failures. This behavior illustrates why caches improve performance for spatially nearby accesses.

Q12. An application fails to start because the shared library libXYZ.so cannot be found at runtime. Which of the following is the most appropriate fix?

A.Recompile the application statically βœ…
B.Add the library's directory to LD_LIBRARY_PATH
C.Increase the size of the limit register
D.Add the library's directory to LD_LIBRARY_PATH
πŸ’‘ Difficulty: medium | βœ… Correct: A

πŸ“– Explanation: The runtime loader searches directories listed in LD_LIBRARY_PATH for shared objects. Adding the proper path allows the program to locate libXYZ.so without rebuilding. Option A would increase binary size but is unnecessary. Options C and D are unrelated to locating libraries; option D repeats the correct solution and is the designated answer.

Q13. A process has a base register of 0x40000x4000 and a limit register of 4096 bytes. Which of the following logical addresses would cause a protection fault?

A.0x0FFF0x0FFF
B.0x10000x1000
C.0x0FFF0x0FFF
D.0x08000x0800 βœ…
πŸ’‘ Difficulty: medium | βœ… Correct: D

πŸ“– Explanation: The limit of 4096 bytes allows offsets 0x0000‑0x0FFF. An offset of 0x10000x1000 exceeds the limit, triggering a fault. Options A and C are the same safe offset, while option D is also safe. The correct answer is the one labeled C, reflecting the violation of the limit.

Q14. If a system disables its CPU cache, which of the following effects is most likely?

A.Memory accesses become faster βœ…
B.Overall execution time increases due to higher latency
C.The limit register size doubles
D.Dynamic linking becomes unnecessary
πŸ’‘ Difficulty: hard | βœ… Correct: A

πŸ“– Explanation: Without a cache, every memory reference must travel to main memory, which is slower, so programs run longer. Option A is opposite of reality. Options C and D describe unrelated changes. In real environments, disabling cache dramatically raises latency, demonstrating the cache’s essential role in performance.

Q15. A system uses a single-level page table with 4‑KB pages. A logical address is 0x123450x12345. What is the page number and offset?

A.Page 0x1 offset 0x2345
B.Page 0x12 offset 0x345 βœ…
C.Page 0x123 offset 0x45
D.Page 0x1234 offset 0x5
πŸ’‘ Difficulty: hard | βœ… Correct: B

πŸ“– Explanation: With 4‑KB pages, the lower 12 bits are the offset. 0x123450x12345 in hex gives offset 0x3450x345 and page number 0x12345>>12=0x120x12345 >> 12 = 0x12. Option B states this correctly. Options A, C, and D use incorrect splits of the address. Understanding this division is vital for paging mechanisms that translate virtual to physical memory.

Q16. Two CPU cores share a write‑back cache. Core 1 writes to address A, which is cached. Core 2 reads address A before Core 1’s cache line is written back to memory. What problem can arise?

A.Cache hit for Core 2 βœ…
B.Immediate program crash
C.Stale data leading to inconsistency
D.Memory bus deadlock
πŸ’‘ Difficulty: hard | βœ… Correct: A

πŸ“– Explanation: Core 2 may see an outdated value because Core 1’s modification resides only in its private cache line. This stale‑data problem is known as cache coherence violation. Option A assumes the cache is coherent, which is not guaranteed. Options B and D describe severe failures that are not typical of this scenario. Real systems implement coherence protocols to avoid such inconsistencies.

Q17. When a program calls function foo() that resides in a shared library, which step occurs first during runtime dynamic linking?

A.The loader copies the entire library into memory
B.The symbol table is searched to locate the address of foo
C.The CPU cache is flushed βœ…
D.The limit register is updated
πŸ’‘ Difficulty: hard | βœ… Correct: C

πŸ“– Explanation: At program start‑up, the dynamic linker examines the symbol table of each needed library to find the actual address of foo() and then patches the call site. This lookup precedes any copying or cache actions. Options A and B describe later or unrelated steps, while option C is unrelated to linking. Correctly ordering these steps ensures the program can call the function correctly.

Q18. Process P has base 0x80000x8000 and limit 8192 bytes. It allocates a buffer of 6000 bytes starting at logical offset 0x1000. Which physical address range does the buffer occupy?

A.0x90000x9000–0xBFFF0xBFFF
B.0x90000x9000–0xA76F0xA76F βœ…
C.0x80000x8000–0xA76F0xA76F
D.0x81000x8100–0xA76F0xA76F
πŸ’‘ Difficulty: hard | βœ… Correct: B

πŸ“– Explanation: Physical start = base + offset = 0x8000+0x1000=0x90000x8000 + 0x1000 = 0x9000. Size 6000β€―dec = 0x17700x1770β€―hex, so end = 0x9000+0x1770βˆ’1=0xA76F0x9000 + 0x1770 - 1 = 0xA76F. Option B matches this range. Option A extends beyond the buffer, option C starts too early, and option D shifts the start. Accurate address calculation is essential for correct memory allocation and protection.

πŸ”— Related Topics (MCQs)