Question: Objective: A C program that translates a virtual address to a physical address, involving a custom-sized fully associative page table . Menu Options: The program

Objective:

A C program that translates a virtual address to a physical address, involving a custom-sized fully associative page table.

Menu Options:

The program translates virtual addresses to a physical address based on selections from a menu, where each choice calls the appropriate procedure.

The possible action inputs are:

Set Parameters

Map Virtual Address

Quit

This program reads all input values from the keyboard.

Upon accepting the parameters, the page table is to be dynamically allocated based on the total number of page frames. The page frames will be mapped to virtual pages, on demand, in the page frame order 0,1,2,3, etc.

Set Parameter Inputs:

The three parameters read are:

The total size of physical memory (in words)

The page size (words/page)

The replacement policy (LRU, FIFO)

Map Virtual Address

When this action option is read, the next value is the virtual address which the program maps into a physical frame and address.

Outputs:

Each time a virtual address is read, two, and possibly three, output lines are displayed. They are:

A Page Fault (if any) in the page table

The original virtual address

The corresponding physical address for the virtual address

Sample Run

Virtual Address Mapping

-----------------------

1) Enter parameters

2) Map virtual address

3) Quit

Enter selection: 1

Enter Main Memory size (words): 2048

Enter page size (words/page): 1024

Enter replacement policy (0=LRU, 1=FIFO): 0

Virtual Address Mapping

-----------------------

NEW CONFIGURATION

*** Main Memory Size: 2048

*** Page Size: 1024

*** Number of Frames: 2

*** Replacement Algorithm: LRU

Virtual Address Mapping

-----------------------

1) Enter parameters

2) Map virtual address

3) Quit

Enter selection: 2

Enter virtual memory address to access: 5000

*** Page Fault!

*** Virtual address 5000 maps to physical address 904

*** VP 4 --> PF 0

Virtual Address Mapping

-----------------------

1) Enter parameters

2) Map virtual address

3) Quit

Enter selection: 2

Enter virtual memory address to access: 2048

*** Page Fault!

*** Virtual address 2048 maps to physical address 1024

*** VP 4 --> PF 0

*** VP 2 --> PF 1

Virtual Address Mapping

-----------------------

1) Enter parameters

2) Map virtual address

3) Quit

Enter selection: 2

Enter virtual memory address to access: 4509

*** Page Hit!

*** Virtual address 4509 maps to physical address 413

*** VP 2 --> PF 1

*** VP 4 --> PF 0

Virtual Address Mapping

-----------------------

1) Enter parameters

2) Map virtual address

3) Quit

Enter selection: 2

Enter virtual memory address to access: 7160

*** Page Fault!

*** Virtual address 7160 maps to physical address 2040

*** VP 4 --> PF 0

*** VP 6 --> PF 1

Virtual Address Mapping

-----------------------

1) Enter parameters

2) Map virtual address

3) Quit

Enter selection: 1

Enter Main Memory size (words): 2048

Enter page size (words/page): 1024

Enter replacement policy (0=LRU, 1=FIFO): 1

Virtual Address Mapping

-----------------------

NEW CONFIGURATION

*** Main Memory Size: 2048

*** Page Size: 1024

*** Number of Frames: 2

*** Replacement Algorithm: FIFO

Virtual Address Mapping

-----------------------

1) Enter parameters

2) Map virtual address

3) Quit

Enter selection: 2

Enter virtual memory address to access: 5000

*** Page Fault!

*** Virtual address 5000 maps to physical address 904

*** VP 4 --> PF 0

Virtual Address Mapping

-----------------------

1) Enter parameters

2) Map virtual address

3) Quit

Enter selection: 2

Enter virtual memory address to access: 2048

*** Page Fault!

*** Virtual address 2048 maps to physical address 1024

*** VP 4 --> PF 0

*** VP 2 --> PF 1

Virtual Address Mapping

-----------------------

1) Enter parameters

2) Map virtual address

3) Quit

Enter selection: 2

Enter virtual memory address to access: 4509

*** Page Hit!

*** Virtual address 4509 maps to physical address 413

*** VP 4 --> PF 0

*** VP 2 --> PF 1

Virtual Address Mapping

-----------------------

1) Enter parameters

2) Map virtual address

3) Quit

Enter selection: 2

Enter virtual memory address to access: 7160

*** Page Fault!

*** Virtual address 7160 maps to physical address 1016

*** VP 2 --> PF 1

*** VP 6 --> PF 0

Virtual Address Mapping

-----------------------

1) Enter parameters

2) Map virtual address

3) Quit

Enter selection: 3

*** Program Terminated Normally

Step by Step Solution

There are 3 Steps involved in it

1 Expert Approved Answer
Step: 1 Unlock blur-text-image
Question Has Been Solved by an Expert!

Get step-by-step solutions from verified subject matter experts

Step: 2 Unlock
Step: 3 Unlock

Students Have Also Explored These Related Databases Questions!