Projects Inventory

Simulation of Virtual Memory Gaming Project in C++

Explanation

  1. Constants:
    • PAGE_SIZE: The maximum number of pages that can be held in memory at a time.
    • Advertisement
    • NUM_PAGES: Total number of unique pages in virtual memory.
  2. VirtualMemory Class:
    • Attributes:
      • pageSize: Maximum capacity of pages in memory.
      • memory: Vector to store pages currently in memory.
      • Advertisement
      • pageTable: Maps page numbers to their positions in memory for quick lookup.
      • pageQueue: Queue to keep track of the order of pages for FIFO replacement.
    • Methods:
      • accessPage(int pageNumber): Handles page access. If the page is not in memory (page fault), it evicts the oldest page (if memory is full) and loads the new page.
      • printMemory(): Prints the current state of memory.
  3. Main Function:
    • Creates an instance of VirtualMemory with the specified page size.
    • Simulates accessing a sequence of pages.
    • Advertisement
    • Calls accessPage for each page in the sequence, then prints the memory state.

Usage

Exit mobile version