assignment代写 | os代写 | c代写 | 计算机组成原理代写 – COMP 222 Computer Organization

COMP 222 Computer Organization

assignment代写 | os代写 | c代写 | 计算机组成原理代写 | assignment代写 – 这是计算机组成原理方面的assignment代写的题目,涉及了底层相关知识

ass代做 assignment代写 代写assignment

assignment #4 Virtual Memory to Physical Memory Address Mapping

Objective:

To map a process (within virtual memory) to physical memory, translating a virtual

(logical) address to a physical address, involving a custom-sized fully associative page

table.

Inputs:

The total size of physical memory (in words)

The page size (words/page)

The replacement policy (LRU, FIFO)

Outputs:

The corresponding physical address for a virtual address

A message indicating a page fault (if any) in the page table

Specification:

The program translates a virtual address within a process to a physical address based on

selecting from a menu of choices. Each choice calls the appropriate procedure, where the

choices are:

1 ) Set parameters for physical memory and page table

2) Map virtual address to physical address

3) Print page table

4 ) Quit program

Upon entering the parameters, the page table is to be dynamically allocated based on the

total number of page frames. The pages of the process will be mapped to the page frames

on demand in the page frame order 0,1,2,3,…

{Hint: When dynamically allocating the page table, initialize each logical page field to – 1

to make it invalid; the page frames do not need to be initialized}

{Hint: In order to maintain the order of references, arrange the virtual page/physical page

frame entries in the page table such that the least-recently-used (or first-in) entry is at

index 0upon revisiting a virtual page (page hit), rearrange the entries, such that the

most recently visited page is moved to the last (or lowest-indexed used) entry of the page

table.}

{Hint: Upon replacement (page fault), decrease the index of each of the valid entries by

1 and insert the new virtual page/page frame entry at the last (or lowest-indexed unused)

entry of the page table}.

What to turn in:

The source code as a single C file uploaded to Canvas (http://canvas.csun.edu) by the

deadline (-20% per consecutive day for late submissions, up to the 4th day).

Sample test run

Virtual memory to Physical memory mapping:

1 ) Enter parameters

  1. Map virtual address to physical address 3 ) Print page table 4 ) Quit Enter selection: 1 Enter physical memory size (words): 2048 Enter page size (words/page): 1024 Enter replacement policy (0=LRU, 1=FIFO): 0 Virtual memory to Physical memory mapping:

  1. Enter parameters
  2. Map virtual address to physical address
  3. Print page table
  4. Quit Enter selection: 2 Enter virtual memory address to access: 5000 Page fault! Virtual memory to Physical memory mapping:

  1. Enter parameters
  2. Map virtual address to physical address
  3. Print page table
  4. Quit Enter selection: 3

| VP | PF |

| 4 | 0 |

Virtual memory to Physical memory mapping:

  1. Enter parameters
  2. Map virtual address to physical address
  3. Print page table
  4. Quit Enter selection: 2 Enter virtual memory address to access: 2048 Page fault! Virtual memory to Physical memory mapping:

  1. Enter parameters
  2. Map virtual address to physical address 3 ) Print page table
  3. Quit Enter selection: 3

| VP | PF |

| 4 | 0 |

| 2 | 1 |

Virtual memory to Physical memory mapping:

  1. Enter parameters
  2. Map virtual address to physical address
  3. Print page table
  4. Quit Enter selection: 2 Enter virtual memory address to access: 4509 Virtual address 4509 maps to physical address 413 Virtual memory to Physical memory mapping:

  1. Enter parameters
  2. Map virtual address to physical address
  3. Print page table
  4. Quit Enter selection: 3

—————–

| VP | PF |

—————–

| 2 | 1 |

—————–

| 4 | 0 |

—————–

Virtual memory to Physical memory mapping:

  1. Enter parameters
  2. Map virtual address to physical address
  3. Print page table
  4. Quit Enter selection: 2 Enter virtual memory address to access: 7160 Page fault! Virtual memory to Physical memory mapping:

  1. Enter parameters
  2. Map virtual address to physical address
  3. Print page table
  4. Quit Enter selection: 3

| VP | PF |

| 4 | 0 |

| 6 | 1 |

Virtual memory to Physical memory mapping:

  1. Enter parameters
  2. Map virtual address to physical address
  3. Print page table
  4. Quit Enter selection: 4