1. Home
  2. Explore
  3. Computer Science
  4. Memory Management Overview

Study methods

Flashcards
Quiz
Fill in the blanks
Written test
Lesson
Notes
Podcast
Content

Memory Management Overview

  • 27Unfamiliar
  • 0Learning
  • 0Familiar
  • 0Mastered
Topic: Memory Management Basics

What is the primary purpose of memory management in a modern operating system?

27 questions

  1. 1

    What is the primary purpose of memory management in a modern operating system?

    1. A

      To store all running programs on the hard disk

    2. B

      To increase the speed of the CPU by reducing memory accesses

    3. C

      To execute programs directly from secondary storage

    4. D

      To allow multiple processes to run concurrently without interfering with each other's memory

    Correct answer
    D

    To 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.

  2. 2

    In the context of memory protection using base and limit registers, what condition must a generated logical address satisfy to be valid?

    1. A

      It must be less than the base register and greater than base - limit

    2. B

      It must be within the range of the operating system's memory

    3. C

      It must be equal to the limit register

    4. D

      It must be greater than or equal to the base register and less than base + limit

    Correct answer
    D

    It 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.

  3. 3

    Hardware address protection is implemented using which components?

    1. A

      The operating system's software routines to validate every memory access

    2. B

      The CPU's arithmetic logic unit (ALU) to perform boundary checks

    3. C

      Special instructions that must be executed before each memory reference

    4. D

      Base and limit registers with hardware logic to compare addresses

    Correct answer
    D

    Base 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.

  4. 4

    What is the difference between a logical address and a physical address?

    1. 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

    2. B

      A logical address is stored in the page table, while a physical address is stored in the TLB

    3. C

      A logical address is used only in paging systems, while a physical address is used in segmentation

    4. D

      A logical address is always the same as the physical address in modern systems

    Correct answer
    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

    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.

  5. 5

    Which hardware component is used to translate logical addresses to physical addresses?

    1. A

      Base and Limit Registers

    2. B

      Translation Lookaside Buffer (TLB)

    3. C

      Memory Management Unit (MMU)

    4. D

      Arithmetic Logic Unit (ALU)

    Correct answer
    C

    Memory 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.

  6. 6

    During address binding, when is the physical address determined if the program is compiled with absolute code?

    1. A

      At compile time

    2. B

      At load time

    3. C

      At execution time

    4. D

      At linking time

    Correct answer
    A

    At 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.

  7. 7

    What is a key advantage of dynamic linking over static linking?

    1. A

      The entire program is loaded at once, reducing overhead

    2. B

      Dynamic linking eliminates the need for a page table

    3. C

      Shared libraries can be loaded into memory once and used by multiple processes

    4. D

      Dynamic linking allows programs to run without any library dependencies

    Correct answer
    C

    Shared 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.

  8. 8

    What is swapping in the context of memory management?

    1. A

      Copying the page table from memory to the TLB

    2. B

      Replacing the operating system kernel with a different one

    3. C

      Exchanging data between CPU registers and main memory

    4. D

      Moving a process out of main memory to backing storage and later bringing it back

    Correct answer
    D

    Moving 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.

  9. 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?

    1. A

      Because other processes may have occupied that address, and the freed memory may be reused

    2. B

      Because the CPU requires a different address for scheduling fairness

    3. C

      Because the backing storage does not preserve the original address

    4. D

      Because the operating system randomly assigns addresses to avoid fragmentation

    Correct answer
    A

    Because 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.

  10. 10

    In contiguous memory allocation, what does the 'first-fit' strategy do?

    1. A

      It allocates memory by moving all processes to one end after compaction

    2. B

      It chooses the largest available hole to leave a big remaining space

    3. C

      It selects the hole that is closest in size to the process to minimize wasted space

    4. D

      It allocates the first hole in memory that is large enough to hold the process

    Correct answer
    D

    It 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.

  11. 11

    Which memory allocation strategy aims to leave the smallest leftover hole possible?

    1. A

      First-fit

    2. B

      Next-fit

    3. C

      Worst-fit

    4. D

      Best-fit

    Correct answer
    D

    Best-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.

  12. 12

    What is external fragmentation?

    1. A

      The TLB has too many entries and overflows

    2. B

      Memory allocated to a process is larger than required, wasting space within the allocated block

    3. C

      Free memory exists but is scattered in small holes, so no single hole is large enough for a process

    4. D

      The page table occupies too much memory

    Correct answer
    C

    Free 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.

  13. 13

    What is internal fragmentation in the context of fixed-sized memory blocks?

    1. A

      The memory used by the page table itself

    2. B

      The overhead of maintaining a free frame list

    3. C

      Free memory that is external to any allocated block

    4. D

      Wasted memory inside an allocated block because the process does not need the entire block

    Correct answer
    D

    Wasted 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.

  14. 14

    What technique can be used to solve external fragmentation by rearranging memory contents?

    1. A

      Swapping

    2. B

      Compaction

    3. C

      Segmentation

    4. D

      Paging

    Correct answer
    B

    Compaction

    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.

  15. 15

    In segmentation, how is a logical address typically represented?

    1. A

      A segment number and an offset within that segment

    2. B

      A physical frame number and an offset

    3. C

      A page number and an offset within that page

    4. D

      A base register value and a limit register value

    Correct answer
    A

    A 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.

  16. 16

    What information does a segment table entry contain?

    1. A

      The segment number and the process ID

    2. B

      The base address of the segment and its length (limit)

    3. C

      The valid bit and the frame number

    4. D

      The page number and frame number

    Correct answer
    B

    The 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.

  17. 17

    What is a key difference between paging and segmentation?

    1. A

      Paging is used only in virtual memory, while segmentation is used in physical memory

    2. B

      Paging does not require a page table, while segmentation always requires a segment table

    3. C

      Paging divides memory into fixed-size frames, while segmentation divides memory into variable-sized segments

    4. D

      Paging uses variable-size blocks, while segmentation uses fixed-size blocks

    Correct answer
    C

    Paging 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.

  18. 18

    In paging, what is a frame?

    1. A

      A fixed-size block of physical memory

    2. B

      A variable-size segment of a process

    3. C

      A fixed-size block of logical memory produced by a process

    4. D

      A cache used to speed up address translation

    Correct answer
    A

    A 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.

  19. 19

    What is the purpose of a page table?

    1. A

      To manage the free frames available in main memory

    2. B

      To store the actual contents of pages in memory

    3. C

      To translate virtual addresses to physical addresses using a cache

    4. D

      To map logical page numbers to physical frame numbers

    Correct answer
    D

    To 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.

  20. 20

    Why does paging result in internal fragmentation on average of half a page per process?

    1. A

      Because the last page of a process is rarely completely full, and the average wasted space is half a page size

    2. B

      Because each page table entry consumes half a frame

    3. C

      Because frames are twice as large as pages

    4. D

      Because the operating system uses half of each frame for bookkeeping

    Correct answer
    A

    Because 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.

  21. 21

    What is a free frame list used for in paging?

    1. A

      To store the page tables of all running processes

    2. B

      To list the pages that are currently in the TLB

    3. C

      To indicate which logical addresses are invalid

    4. D

      To keep track of which frames in physical memory are available for allocation

    Correct answer
    D

    To 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.

  22. 22

    Where is the page table stored?

    1. A

      In the TLB

    2. B

      In the CPU registers

    3. C

      On the backing storage (disk)

    4. D

      In main memory

    Correct answer
    D

    In 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.

  23. 23

    How does a Translation Lookaside Buffer (TLB) improve memory access performance?

    1. A

      It caches recent page-to-frame mappings and searches them in parallel

    2. B

      It increases the page size to reduce the number of entries

    3. C

      It stores the actual data pages for fast retrieval

    4. D

      It replaces the page table entirely, reducing memory accesses

    Correct answer
    A

    It 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.

  24. 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)?

    1. A

      101 ns

    2. B

      121 ns

    3. C

      220 ns

    4. D

      120 ns

    Correct answer
    A

    101 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:

  25. 25

    What does a valid/invalid bit in a page table entry indicate?

    1. A

      Whether the page is currently in the TLB

    2. B

      Whether the page is readable or writable

    3. C

      Whether the frame is free or occupied

    4. D

      Whether the page is in the process's logical address space

    Correct answer
    D

    Whether 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).

  26. 26

    Why can shared code (e.g., DLLs) be marked as reentrant?

    1. A

      Because it is stored in the TLB for fast access

    2. B

      Because it is loaded at a fixed address that never changes

    3. C

      Because it is written in a language that does not require memory management

    4. D

      Because the code does not modify itself and can be safely executed by multiple processes concurrently

    Correct answer
    D

    Because 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.

  27. 27

    In a system with paging, how does the CPU handle a logical address?

    1. A

      It sends the address to the TLB first without any splitting

    2. B

      It splits the address into a page number and an offset, then uses the page number to index the page table

    3. C

      It uses the entire address as a physical address directly

    4. D

      It divides the address into segment number and offset

    Correct answer
    B

    It 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).

Question 1 of 27
Question 1 of 27

Ask anything

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

FlashcardsQuizFill in the blanksWritten testLessonNotesPodcastContent