Virtual Memory and RAM

Choose a study mode

Play Quiz
Study Flashcards
Spaced Repetition
Chat to Lesson

Podcast

Play an AI-generated podcast conversation about this lesson

Questions and Answers

Which of the following is a characteristic of Static RAM (SRAM) compared to Dynamic RAM (DRAM)?

  • SRAM is generally faster and more expensive than DRAM. (correct)
  • SRAM stores each bit with a capacitor.
  • SRAM is slower and cheaper than DRAM.
  • SRAM requires periodic refreshing of its data.

Which memory type retains data even when power is removed?

  • SRAM
  • DRAM
  • Non-Volatile Memory (NVM) (correct)
  • Cache Memory

Which of the following best describes the primary function of firmware programs stored in ROM?

  • To store user's personal files and documents.
  • To provide initial instructions for hardware components like disks and network cards during system startup. (correct)
  • To replace RAM in systems requiring high speed.
  • To serve as cache memory in high end systems.

What key property of computer programs is leveraged to bridge the CPU-Memory gap?

<p>Locality (B)</p> Signup and view all the answers

Which type of locality is exhibited when a program accesses the same memory location multiple times within a short period?

<p>Temporal locality (B)</p> Signup and view all the answers

Consider the following code snippet:

for (i = 0; i < N; i++)
  array[i] = array[i] + 1;

What type of locality is primarily exhibited in accessing array[i]?

<p>Spatial locality (A)</p> Signup and view all the answers

Which of the following is a fundamental property of memory hierarchies?

<p>Faster storage technologies are more expensive per byte and have less capacity. (C)</p> Signup and view all the answers

In a memory hierarchy, what is the role of a cache?

<p>To act as a staging area for a subset of data from a larger, slower device. (A)</p> Signup and view all the answers

What happens when requested data is found in the cache?

<p>A cache hit occurs, and the data is provided directly from the cache. (A)</p> Signup and view all the answers

Which of the following is NOT a type of cache miss?

<p>Hot miss (B)</p> Signup and view all the answers

Which scenario primarily leads to a conflict miss in a cache?

<p>Multiple data objects map to the same cache block. (A)</p> Signup and view all the answers

What is the main purpose of using virtual addresses in a system?

<p>To simplify memory management for processes and provide memory protection. (D)</p> Signup and view all the answers

What hardware component is essential for translating virtual addresses to physical addresses?

<p>MMU (Memory Management Unit) (B)</p> Signup and view all the answers

How is the physical address calculated in a system using fixed partitions?

<p>physical address = virtual address + base register (B)</p> Signup and view all the answers

What is a key disadvantage of using fixed partitions for memory management?

<p>Internal fragmentation (C)</p> Signup and view all the answers

In variable partitions, what hardware register is used to prevent a process from accessing memory outside of its allocated partition?

<p>Both base and limit register (C)</p> Signup and view all the answers

What is a primary disadvantage of using variable partitions for memory management?

<p>External fragmentation (B)</p> Signup and view all the answers

What is the main advantage of segmentation over variable partitions?

<p>Allocation of memory in logically related units (C)</p> Signup and view all the answers

In segmentation, what information is contained within a segment table?

<p>Both the base address and limit (size) of each segment (B)</p> Signup and view all the answers

Which of the following best describes the concept of paging?

<p>Dividing virtual address space into fixed-size blocks (A)</p> Signup and view all the answers

How does paging solve the problem of external fragmentation?

<p>By using fixed-size units in both physical and virtual memory. (A)</p> Signup and view all the answers

From a process perspective, how is memory viewed when using paging?

<p>As a single, contiguous address space (D)</p> Signup and view all the answers

In paging, what is a Virtual Page Number (VPN)?

<p>An index into the page table (A)</p> Signup and view all the answers

What is the role of a Page Table Entry (PTE) in paging?

<p>To map a virtual page number to a page frame number (D)</p> Signup and view all the answers

In a paging system, if the page size is 4KB, how many bits are used for the offset within a page?

<p>12 bits (A)</p> Signup and view all the answers

What does the 'Valid' bit in a Page Table Entry (PTE) indicate?

<p>Whether the PTE can be used for address translation (D)</p> Signup and view all the answers

Which of the following is a limitation of paging?

<p>Memory reference overhead (D)</p> Signup and view all the answers

What is the primary advantage of using solid state drives (SSDs) over traditional rotating disks?

<p>Faster access times and greater durability (B)</p> Signup and view all the answers

Which memory management technique allows a program to run on a machine with less physical memory than the program needs?

<p>Virtual Memory (C)</p> Signup and view all the answers

How does memory hierarchy address the CPU-Memory gap?

<p>Caching frequently accessed data in faster memory levels (D)</p> Signup and view all the answers

What is the primary goal of the 'placement policy' in cache design?

<p>To determine where incoming data should be stored in the cache. (A)</p> Signup and view all the answers

What purpose do protection bits serve in page table entries (PTEs)?

<p>To define the operations allowed on a page, such as read, write, or execution. (C)</p> Signup and view all the answers

Which of the following is a key advantage of paging?

<p>Paging facilitates virtual memory implementation. (D)</p> Signup and view all the answers

Which of the following memory technologies is generally the fastest to access?

<p>Static RAM (SRAM) (C)</p> Signup and view all the answers

What is the 'replacement policy' in the context of caching?

<p>A strategy for deciding which block to evict from the cache when a new block needs to be stored. (D)</p> Signup and view all the answers

In the context of virtual memory, what is the main role of the operating system (OS)?

<p>To determine location of data in physical memory. (B)</p> Signup and view all the answers

How do temporal and spatial locality contribute to the effectiveness of caching?

<p>They ensure more frequently and nearby accessed data are available in the cache. (C)</p> Signup and view all the answers

What is universal memory expected to replace?

<p>Both DRAM and disk drives (C)</p> Signup and view all the answers

Flashcards

What is a RAM cell?

A basic storage unit in RAM, typically storing one bit of data.

What is Static RAM (SRAM)?

RAM that retains data indefinitely as long as power is supplied; it's faster but more expensive.

What is Dynamic RAM (DRAM)?

RAM that stores data using a capacitor and requires periodic refreshing; slower but cheaper.

What are Nonvolatile memories (NVMs)?

Memory that retains data without power, used for firmware, solid-state drives and caches.

Signup and view all the flashcards

What is Principle of Locality?

Programs tend to use data and instructions with addresses near or equal to those they have used recently.

Signup and view all the flashcards

What is Temporal locality?

Recently referenced items are likely to be referenced again in the near future.

Signup and view all the flashcards

What is Spatial locality?

Items with nearby addresses tend to be referenced close together in time.

Signup and view all the flashcards

What is memory hierarchy?

An organization of memory and storage systems using different layers of storage.

Signup and view all the flashcards

What is Cache?

A smaller, faster memory that serves as a staging area for a subset of data in a larger, slower memory.

Signup and view all the flashcards

What is a Cache hit?

When requested data is found in the cache.

Signup and view all the flashcards

What is Cache miss?

When requested data is not found in the cache and must be fetched from main memory.

Signup and view all the flashcards

What is a Cold (compulsory) miss?

Occurs when a block is first brought into the cache.

Signup and view all the flashcards

What is a Conflict miss?

Occurs when blocks map to the same cache location, evicting each other.

Signup and view all the flashcards

What is a Capacity miss?

Occurs when the cache is too small to hold all the blocks needed by a program.

Signup and view all the flashcards

What are Virtual addresses?

Addresses used by a program, independent of physical memory addresses.

Signup and view all the flashcards

What is virtual address space?

The range of virtual addresses a process can use.

Signup and view all the flashcards

What are fixed partitions?

Physical memory is divided into fixed size partitions.

Signup and view all the flashcards

What is Internal fragmentation?

Memory within a partition that is not used by a process.

Signup and view all the flashcards

What are variable partitions?

Memory is divided into variable sized partitions.

Signup and view all the flashcards

What is External fragmentation?

Free memory is scattered throughout physical memory; unusable.

Signup and view all the flashcards

What is Segmentation?

Memory is divided into logically related units.

Signup and view all the flashcards

What is Paging?

Splitting virtual address space into multiple partitions (pages); allows each page to go anywhere in physical memory.

Signup and view all the flashcards

What is Virtual Page Number (VPN)?

The number of pages to use in virtual address.

Signup and view all the flashcards

What is Page Frame Number (PFN)?

Page table determines location of a physical page given a virtual page.

Signup and view all the flashcards

What is the Modify bit?

Says whether or not corresponding page has been written.

Signup and view all the flashcards

What is the Reference bit?

Says whether or not the page has been accessed.

Signup and view all the flashcards

What is the Valid bit?

Says whether or not PTE can be used.

Signup and view all the flashcards

What are Protection bits?

Restrict memory use.

Signup and view all the flashcards

Study Notes

Virtual Memory

  • Applications interact with the operating system through abstractions like processes, file systems, and virtual memory.
  • The operating system manages hardware resources such as the CPU, disk, and RAM.

Random-Access Memory (RAM) Features

  • RAM is commonly packaged as a chip.
  • The basic storage unit in RAM is a cell, which stores one bit.
  • Multiple RAM chips combine to form system memory.

Static RAM (SRAM)

  • Each SRAM cell stores a bit using a four or six-transistor circuit.
  • SRAM retains data indefinitely while powered.
  • SRAM is resistant to electrical noise and radiation.
  • SRAM is faster but more expensive than DRAM.

Dynamic RAM (DRAM)

  • Each DRAM cell stores a bit using a capacitor, accessed by one transistor.
  • DRAM requires periodic refreshing of its value every 10-100 ms.
  • DRAM is more sensitive to disturbances than SRAM.
  • DRAM is slower but cheaper than SRAM.

SRAM vs DRAM Summary

  • SRAM cells use 4 to 6 transistors, while DRAM cells use 1 transistor.
  • SRAM has an access time of 1X, whereas DRAM has an access time of 10X.
  • SRAM does not need refreshing, but DRAM does.
  • SRAM may not need EDC, but DRAM does.
  • SRAM is 100 times more expensive than DRAM.
  • SRAM applications include cache memories.
  • DRAM applications include main memories and frame buffers.

Nonvolatile Memories (NVMs)

  • DRAM and SRAM are volatile, losing data without power.
  • NVMs retain data even without power.
  • Read-only memory(ROM) is programmed during production.
  • Programmable ROM (PROM) can be programmed once.
  • Eraseable PROM (EPROM) can be bulk erased using UV or X-Ray.
  • Electrically eraseable PROM (EEPROM) can be erased electronically and Flash memory, EEPROMs with partial (sector) erase capability, wear out after about 100,000 erasures.
  • Phase Change Memories (PCMs) wear out as well.
  • Many new NVMs are emerging at various development stages.

NVM Uses

  • Firmware programs are stored in ROM for BIOS, disk controllers, network cards, graphics accelerators, and security subsystems.
  • Solid state disks replace rotating disks in devices like thumb drives, smartphones, tablets, and laptops.
  • NVMs are used in high-end system caches.
  • Universal memory is expected to replace both DRAM and disk drives.

The CPU-Memory Gap

  • The speed disparity between DRAM, disk, and CPU is increasing.
  • Locality is essential for bridging the CPU-Memory gap.

Locality of Reference

  • Programs tend to access data and instructions with addresses near or equal to those recently used.
  • Temporal locality refers to the tendency to reuse recently accessed items.
  • Spatial locality refers to the tendency to access items with nearby addresses at close times.

Locality Example: Data References

  • Accessing array elements in succession exhibits spatial locality.
  • Repeatedly referencing a variable exhibits temporal locality.

Locality Example: Instruction References

  • Executing instructions in sequence exhibits spatial locality.
  • Cycling through a loop repeatedly exhibits temporal locality.

Qualitative Estimates of Locality

  • Identifying a code's locality is essential for professional programmers.

Memory Hierarchies

  • Properties of hardware and software include the cost per byte of fast storage technologies, CPU and main memory speed disparity and programs exhibiting good locality.
  • These properties are complementary, for an approach to organizing memory and storage systems known as a memory hierarchy.

Memory Hierarchy: Caching

  • Caching is used in the memory hierarchy.

Memory Hierarchy: Example

  • CPU registers hold words retrieved from L1 cache.
  • L1 cache holds cache lines from L2 cache (SRAM).
  • L2 cache holds cache lines from main memory (DRAM).
  • Main memory holds disk blocks from local disks.
  • Local disks hold files from remote network servers.

Memory Hierarchy

  • A smaller, faster storage device acting as a staging area for a subset of data in a larger, slower device is cache.
  • Each layer of a memory hierarchy caches the layer below.
  • Memory hierarchies work due to locality, so hit rate is significant although it’s smaller and storage can be slower at level k+1.
  • The memory hierarchy allows programs to process data at the rate of fast storage near the top.

Cache Concepts

  • Smaller, faster memory caches a subset of the blocks.
  • Data is copied in block-sized transfer units.
  • Larger, slower memory is viewed as partitioned into blocks.
  • When data is needed and found in the cache, it is a cache hit.
  • When data is not in the cache, it is a cache miss.
  • On a miss, the block is fetched from memory and stored in the cache.

Cache Concepts: Miss

  • Placement policy determines where the block is stored.
  • Replacement policy determines which block is evicted (victim).

Types of Cache Misses

  • Cold (compulsory) miss occurs when the cache is empty.
  • Conflict miss occurs when multiple data objects map to the same level k block.
  • Capacity miss occurs when the set of active cache blocks (working set) is larger than the cache.

Multiprogramming

  • Overlap I/O and CPU of multiple jobs.
  • Share physical memory across multiple processes.

Virtual Addresses

  • Virtual addresses are used to manage the memory of processes.
  • Instructions executed by the CPU issue virtual addresses.
  • Virtual addresses are independent of the actual physical location.
  • The OS determines the location of data in physical memory.
  • Hardware translates virtual addresses into physical addresses, also the process's virtual address space is the set of virtual addresses.

Virtual Addresses: Translation

  • The translation from virtual to physical addresses requires hardware support and OS management algorithms.
  • Protection is needed to restrict which addresses jobs can use.
  • Fast translation, lookups need to be fast and Updating memory hardware needs to be on context switch.

Fixed Partitions: Physical Memory

  • Physical memory is divided into fixed-size partitions.
  • Each partition has the same allocated memory.
  • The base register is loaded by the OS when switching to a process.
  • Physical address calculation= Virtual address + base register

Fixed Partition Advantages

  • Easy to implement, as base register is the one requirement
  • Need to verify that offset is less than fixed partition size.
  • Enables fast context switch.

Fixed Partition Problems

  • Internal fragmentation: memory in a partition not used by a process cannot be available to other processes.
  • Partition size: one size does not fit all (very large processes?).

Variable Partitions

  • Natural extension - physical memory is broken up into variable sized partitions
  • Hardware requirements: base register and limit register
  • Physical address = virtual address + base register
  • The limit register is a fault if (virtual address > limit).

Variable Partition Advantages

  • No internal fragmentation because just enough is allocated for the process.

Variable Partition Problems

  • External fragmentation job loading and unloading produces empty holes scattered throughout memory.

Memory Segmentation

  • It supports segmentation of memory into logically related units such as modules, procedures, stack, data and files, Units of memory from user’s perspective.
  • Segments support for both variable sized partitions = 1 segment/process and many segments/process.
  • It is a fixed or variable partition
  • Hardware support has to include multiple base/limit pairs, with named segments by #, to index into table, hence virtual addresses become <segment #, offset>.

Paging

  • It splits the virtual address space into multiple partition, each can go anywhere, external fragmentation is being solved by using fixed sized units in both physical and virtual memory.
  • Need the OS to keep track.

Process Perspective of Paging

  • Processes view memory as one contiguous address space from 0 through N that is, virtual address space (VAS) .
  • Pages are scattered throughout the physical storage.
  • A program cannot reference memory outside of its VAS, as the memory is invisible to it.
  • Address "0x1000” maps to different physical addresses in different processes.

Paging: Translating Addresses

  • It contains the virutal (virtual page number and offset).
  • The virtual page number (VPN) is an index into a page table.
  • The page table determines page frame number (PFN).
  • Physical address is PFN::offset.
  • It maps virtual page number (VPN) to page frame number (PFN) and has a one to one link between the page table entry (PTE) to the virtual address space.

Paging Example

  • Pages are 4KB each.
  • Offset is 12 bits (because 4KB = 212 bytes).
  • VPN is 20 bits (32 bits is the length of every virtual address).
  • Virtual address is 0x7468, then virtual page is 0x7 and offset is 0x468 as Page table entry 0x7 contains 0x2000 Page frame number is 0x2000.
  • The seventh virtual page is at address 0x2000 (2nd physical page).
  • The physical address = 0x2000 + 0x468 = 0x2468.

Page Table Entries (PTEs)

  • Page table entries control mapping, contain modify, reference, valid and protection bits but also determine the page frame number (PFN) determines physical page.

Paging Advantages

  • Memory is easily allocated due to being a fixed size chunk but that it is just extracted from the list.
  • External fragmentation is gone.
  • Enables to simplify protection and the chunks are the same size.

Paging Limitations

  • Internal fragmentation may still exist, as the Proccess may not use memory in multiples of a page.
  • Memory reference overhead, as it is more lookups per address lookup for page table then memory but also can grow significantly the required memory for the page table.

Studying That Suits You

Use AI to generate personalized quizzes and flashcards to suit your learning preferences.

Quiz Team

Related Documents

More Like This

Mémoire informatique
45 questions

Mémoire informatique

InviolableBoolean avatar
InviolableBoolean
Integrated Circuits and Memory Types
17 questions
SRAM vs DRAM: Memory Cell Comparison
25 questions
Use Quizgecko on...
Browser
Browser