Memory Management Overview
- 27Unfamiliar
- 0Learning
- 0Familiar
- 0Mastered
What is the primary purpose of memory management in a modern operating system?
What is the primary purpose of memory management in a modern operating system?
27 questions
- 1
What is the primary purpose of memory management in a modern operating system?
- A
To store all running programs on the hard disk
- B
To increase the speed of the CPU by reducing memory accesses
- C
To execute programs directly from secondary storage
- D
To allow multiple processes to run concurrently without interfering with each other's memory
Correct answer
DTo allow multiple processes to run concurrently without interfering with each other's memory
Explanation
Memory management ensures that multiple processes can reside in memory simultaneously without overwriting each other's memory, which is essential for multitasking.
- A
- 2
In the context of memory protection using base and limit registers, what condition must a generated logical address satisfy to be valid?
- A
It must be less than the base register and greater than base - limit
- B
It must be within the range of the operating system's memory
- C
It must be equal to the limit register
- D
It must be greater than or equal to the base register and less than base + limit
Correct answer
DIt must be greater than or equal to the base register and less than base + limit
Explanation
The logical address is checked against the base and limit registers: address >= base and address < base + limit. If the address falls outside this range, a trap is generated.
- A
- 3
Hardware address protection is implemented using which components?
- A
The operating system's software routines to validate every memory access
- B
The CPU's arithmetic logic unit (ALU) to perform boundary checks
- C
Special instructions that must be executed before each memory reference
- D
Base and limit registers with hardware logic to compare addresses
Correct answer
DBase and limit registers with hardware logic to compare addresses
Explanation
Hardware address protection uses dedicated registers (base and limit) and logic circuits to quickly verify that each memory access is within the allowed range without slowing down the CPU.
- A
- 4
What is the difference between a logical address and a physical address?
- A
A logical address is generated by the CPU and is relative to the process start, while a physical address is the actual location in main memory
- B
A logical address is stored in the page table, while a physical address is stored in the TLB
- C
A logical address is used only in paging systems, while a physical address is used in segmentation
- D
A logical address is always the same as the physical address in modern systems
Correct answer
AA logical address is generated by the CPU and is relative to the process start, while a physical address is the actual location in main memory
Explanation
The logical address is the address seen by the process (starting at 0), while the physical address is where the data actually resides in RAM. The MMU translates one to the other.
- A
- 5
Which hardware component is used to translate logical addresses to physical addresses?
- A
Base and Limit Registers
- B
Translation Lookaside Buffer (TLB)
- C
Memory Management Unit (MMU)
- D
Arithmetic Logic Unit (ALU)
Correct answer
CMemory Management Unit (MMU)
Explanation
The MMU is the hardware component that maps logical addresses to physical addresses, often using registers such as the relocation register.
- A
- 6
During address binding, when is the physical address determined if the program is compiled with absolute code?
- A
At compile time
- B
At load time
- C
At execution time
- D
At linking time
Correct answer
AAt compile time
Explanation
If the program is compiled with absolute addresses, the memory locations are fixed at compile time. This is used in systems where the program's location will never change, such as embedded systems.
- A
- 7
What is a key advantage of dynamic linking over static linking?
- A
The entire program is loaded at once, reducing overhead
- B
Dynamic linking eliminates the need for a page table
- C
Shared libraries can be loaded into memory once and used by multiple processes
- D
Dynamic linking allows programs to run without any library dependencies
Correct answer
CShared libraries can be loaded into memory once and used by multiple processes
Explanation
Dynamic linking allows shared libraries (DLLs) to be loaded into memory only when needed and shared among processes, reducing memory usage and enabling updates to libraries independently.
- A
- 8
What is swapping in the context of memory management?
- A
Copying the page table from memory to the TLB
- B
Replacing the operating system kernel with a different one
- C
Exchanging data between CPU registers and main memory
- D
Moving a process out of main memory to backing storage and later bringing it back
Correct answer
DMoving a process out of main memory to backing storage and later bringing it back
Explanation
Swapping involves removing a process from memory to free space and later reloading it from backing storage (usually disk). This allows more processes to be active than the physical memory can hold at once.
- A
- 9
When a process is swapped out and later swapped back in, why can't it be guaranteed to return to the same memory address?
- A
Because other processes may have occupied that address, and the freed memory may be reused
- B
Because the CPU requires a different address for scheduling fairness
- C
Because the backing storage does not preserve the original address
- D
Because the operating system randomly assigns addresses to avoid fragmentation
Correct answer
ABecause other processes may have occupied that address, and the freed memory may be reused
Explanation
The original memory location may have been allocated to another process while the swapped-out process was on disk. Therefore, the process must be loaded into a different location, and its addresses must be updated.
- A
- 10
In contiguous memory allocation, what does the 'first-fit' strategy do?
- A
It allocates memory by moving all processes to one end after compaction
- B
It chooses the largest available hole to leave a big remaining space
- C
It selects the hole that is closest in size to the process to minimize wasted space
- D
It allocates the first hole in memory that is large enough to hold the process
Correct answer
DIt allocates the first hole in memory that is large enough to hold the process
Explanation
First-fit scans memory from the beginning and uses the first hole that is large enough. It is simple and fast but may create small holes over time.
- A
- 11
Which memory allocation strategy aims to leave the smallest leftover hole possible?
- A
First-fit
- B
Next-fit
- C
Worst-fit
- D
Best-fit
Correct answer
DBest-fit
Explanation
Best-fit searches the entire list of free holes and picks the one that is closest in size to the requested amount, leaving the smallest leftover fragment. However, it can lead to many very small holes.
- A
- 12
What is external fragmentation?
- A
The TLB has too many entries and overflows
- B
Memory allocated to a process is larger than required, wasting space within the allocated block
- C
Free memory exists but is scattered in small holes, so no single hole is large enough for a process
- D
The page table occupies too much memory
Correct answer
CFree memory exists but is scattered in small holes, so no single hole is large enough for a process
Explanation
External fragmentation occurs when overall free memory is sufficient but is divided into small, non-contiguous holes. No single hole can accommodate a new process, even though total free memory is enough.
- A
- 13
What is internal fragmentation in the context of fixed-sized memory blocks?
- A
The memory used by the page table itself
- B
The overhead of maintaining a free frame list
- C
Free memory that is external to any allocated block
- D
Wasted memory inside an allocated block because the process does not need the entire block
Correct answer
DWasted memory inside an allocated block because the process does not need the entire block
Explanation
Internal fragmentation happens when a memory block allocated to a process is larger than the process requires. The unused space inside the block is wasted.
- A
- 14
What technique can be used to solve external fragmentation by rearranging memory contents?
- A
Swapping
- B
Compaction
- C
Segmentation
- D
Paging
Correct answer
BCompaction
Explanation
Compaction moves all allocated processes to one end of memory, creating one large free block. This eliminates external fragmentation but requires dynamic relocation and is time-consuming.
- A
- 15
In segmentation, how is a logical address typically represented?
- A
A segment number and an offset within that segment
- B
A physical frame number and an offset
- C
A page number and an offset within that page
- D
A base register value and a limit register value
Correct answer
AA segment number and an offset within that segment
Explanation
Segmentation divides a process into variable-sized segments (e.g., code, data, stack). A logical address consists of a segment number (index into segment table) and an offset.
- A
- 16
What information does a segment table entry contain?
- A
The segment number and the process ID
- B
The base address of the segment and its length (limit)
- C
The valid bit and the frame number
- D
The page number and frame number
Correct answer
BThe base address of the segment and its length (limit)
Explanation
Each segment table entry stores the base (starting physical address) and limit (length) of the segment, allowing the MMU to check offsets and translate addresses.
- A
- 17
What is a key difference between paging and segmentation?
- A
Paging is used only in virtual memory, while segmentation is used in physical memory
- B
Paging does not require a page table, while segmentation always requires a segment table
- C
Paging divides memory into fixed-size frames, while segmentation divides memory into variable-sized segments
- D
Paging uses variable-size blocks, while segmentation uses fixed-size blocks
Correct answer
CPaging divides memory into fixed-size frames, while segmentation divides memory into variable-sized segments
Explanation
Paging uses fixed-size units (pages/frames), eliminating external fragmentation. Segmentation uses variable-size segments based on the logical divisions of a program.
- A
- 18
In paging, what is a frame?
- A
A fixed-size block of physical memory
- B
A variable-size segment of a process
- C
A fixed-size block of logical memory produced by a process
- D
A cache used to speed up address translation
Correct answer
AA fixed-size block of physical memory
Explanation
Physical memory is divided into fixed-size blocks called frames. Logical memory is divided into pages of the same size. A page is placed into a frame.
- A
- 19
What is the purpose of a page table?
- A
To manage the free frames available in main memory
- B
To store the actual contents of pages in memory
- C
To translate virtual addresses to physical addresses using a cache
- D
To map logical page numbers to physical frame numbers
Correct answer
DTo map logical page numbers to physical frame numbers
Explanation
The page table is a per-process data structure that contains mappings from each logical page number to the corresponding physical frame number. It is used by the MMU during address translation.
- A
- 20
Why does paging result in internal fragmentation on average of half a page per process?
- A
Because the last page of a process is rarely completely full, and the average wasted space is half a page size
- B
Because each page table entry consumes half a frame
- C
Because frames are twice as large as pages
- D
Because the operating system uses half of each frame for bookkeeping
Correct answer
ABecause the last page of a process is rarely completely full, and the average wasted space is half a page size
Explanation
The final page of a process is partially filled, wasting the remaining space in that frame. Since the amount of waste is uniformly distributed between 0 and the page size, the average waste is half the page size.
- A
- 21
What is a free frame list used for in paging?
- A
To store the page tables of all running processes
- B
To list the pages that are currently in the TLB
- C
To indicate which logical addresses are invalid
- D
To keep track of which frames in physical memory are available for allocation
Correct answer
DTo keep track of which frames in physical memory are available for allocation
Explanation
The operating system maintains a free frame list to know which frames are empty. When a new process loads, pages are assigned to frames from this list.
- A
- 22
Where is the page table stored?
- A
In the TLB
- B
In the CPU registers
- C
On the backing storage (disk)
- D
In main memory
Correct answer
DIn main memory
Explanation
The page table is stored in main memory. The CPU uses dedicated registers (like the page-table base register) to point to it. This means that a memory access requires two accesses: one for the page table and one for the actual data.
- A
- 23
How does a Translation Lookaside Buffer (TLB) improve memory access performance?
- A
It caches recent page-to-frame mappings and searches them in parallel
- B
It increases the page size to reduce the number of entries
- C
It stores the actual data pages for fast retrieval
- D
It replaces the page table entirely, reducing memory accesses
Correct answer
AIt caches recent page-to-frame mappings and searches them in parallel
Explanation
The TLB is an associative cache that holds recently used page table entries. It provides fast parallel lookup, avoiding the need to access the page table in memory for every address translation.
- A
- 24
If a TLB hit rate is 99%, the TLB search time is 20 ns, and memory access time is 100 ns, what is the effective access time (EAT)?
- A
101 ns
- B
121 ns
- C
220 ns
- D
120 ns
Correct answer
A101 ns
Explanation
EAT = (hit rate) * (TLB time + memory time) + (miss rate) * (TLB time + 2 * memory time) = 0.99 * (20+100) + 0.01 * (20+200) = 0.99120 + 0.01220 = 118.8 + 2.2 = 121 ns. Wait, recalc: 0.99120=118.8, 0.01220=2.2, sum=121 ns. But options: 121 ns is not listed? Let's check options:
- A
- 25
What does a valid/invalid bit in a page table entry indicate?
- A
Whether the page is currently in the TLB
- B
Whether the page is readable or writable
- C
Whether the frame is free or occupied
- D
Whether the page is in the process's logical address space
Correct answer
DWhether the page is in the process's logical address space
Explanation
The valid/invalid bit indicates whether a page is part of the process's logical address space. A valid bit means the page is in memory and belongs to the process; invalid means the process should not access that page (generates a trap).
- A
- 26
Why can shared code (e.g., DLLs) be marked as reentrant?
- A
Because it is stored in the TLB for fast access
- B
Because it is loaded at a fixed address that never changes
- C
Because it is written in a language that does not require memory management
- D
Because the code does not modify itself and can be safely executed by multiple processes concurrently
Correct answer
DBecause the code does not modify itself and can be safely executed by multiple processes concurrently
Explanation
Reentrant code does not modify itself during execution, allowing multiple processes to share the same physical pages of code while each having its own private data pages.
- A
- 27
In a system with paging, how does the CPU handle a logical address?
- A
It sends the address to the TLB first without any splitting
- B
It splits the address into a page number and an offset, then uses the page number to index the page table
- C
It uses the entire address as a physical address directly
- D
It divides the address into segment number and offset
Correct answer
BIt splits the address into a page number and an offset, then uses the page number to index the page table
Explanation
The logical address is divided into two parts: the page number (used to look up the page table) and the offset (used to locate the exact byte within the frame).
- A

Ask anything
We've read this whole study set, so questions about it get the best answers.