Please write a program in C++ to stimulate the internal operation of MMU with single-level page...
Fantastic news! We've Found the answer you've been seeking!
Question:
Transcribed Image Text:
Please write a program in C++ to stimulate the internal operation of MMU with single-level page table. Description The virtual address is split into a virtual page number (high-order bits) and an offset (low-order bits). With a 16-bit address and a 4-KB page size, the upper 4 bits could specify one of the 16 virtual pages and the lower 12 bits would then specify the byte offset (0 to 4095) within the selected page. The virtual page number is used as an index into the page table to find the entry for that virtual page. From the page table entry, the page frame number (if any) is found. The page frame number is attached to the high-order end of the offset, replacing the virtual page number, to form a physical address that can be sent to the memory. Thus, the purpose of the page table is to map virtual pages onto page frames. Mathematically speaking, the page table is a function, with the virtual page number as argument and the physical frame number as result. Using the result of this function, the virtual page field in a virtual address can be replaced by a page frame field, thus forming a physical memory address. Notice (1) The page table is a single-level page table. (2) The related data structures and the global object pageTable were defined as follows, which can be accessed directly by your code. #define N 16 struct SPageTableEntry { }; unsigned char pageFramNr: 3; bool pa; struct SPageTable { SPageTableEntry pte[N]; SPageTable(); // constructor, already defined by the system to init pageTable. } pageTable; (3) You only need to write the main function in C++. (4) Don't return non-zero value in your main function, or it is regarded as a program error by the OJ system. (5) Input an unsigned short variable as a logical address. If the logical address is greater than 65535, then it is 65535. (6) Check the Present/absent bit, if it is 1, then convert the logical address into the corresponding physical address, or output "Page fault!". (7) Figure 1 explains the principle of converting a logical (virtual) addresse to the physical addresse. The values in the page table in the figure may be different from the values in the object page Table! Page table 10000000000100 15 000 0 14 000 0 13 000 0 12 000 0 11 111 1 10 000 0 9 101 1 8 000 0 000 0 000 0 011 1 4 100 1 3 000 1 2 110 1 1 001 1 0 010 1 7 6 5 110 -Present/ absent bit Virtual page = 2 is used as an index into the page table 12-bit offset copied directly from input to output 0010000000000100 Outgoing physical address (24580) Incoming virtual address (8196) Figure 1. Convert a logical address (virtual address) with 16 bits to the physical address. Please write a program in C++ to stimulate the internal operation of MMU with single-level page table. Description The virtual address is split into a virtual page number (high-order bits) and an offset (low-order bits). With a 16-bit address and a 4-KB page size, the upper 4 bits could specify one of the 16 virtual pages and the lower 12 bits would then specify the byte offset (0 to 4095) within the selected page. The virtual page number is used as an index into the page table to find the entry for that virtual page. From the page table entry, the page frame number (if any) is found. The page frame number is attached to the high-order end of the offset, replacing the virtual page number, to form a physical address that can be sent to the memory. Thus, the purpose of the page table is to map virtual pages onto page frames. Mathematically speaking, the page table is a function, with the virtual page number as argument and the physical frame number as result. Using the result of this function, the virtual page field in a virtual address can be replaced by a page frame field, thus forming a physical memory address. Notice (1) The page table is a single-level page table. (2) The related data structures and the global object pageTable were defined as follows, which can be accessed directly by your code. #define N 16 struct SPageTableEntry { }; unsigned char pageFramNr: 3; bool pa; struct SPageTable { SPageTableEntry pte[N]; SPageTable(); // constructor, already defined by the system to init pageTable. } pageTable; (3) You only need to write the main function in C++. (4) Don't return non-zero value in your main function, or it is regarded as a program error by the OJ system. (5) Input an unsigned short variable as a logical address. If the logical address is greater than 65535, then it is 65535. (6) Check the Present/absent bit, if it is 1, then convert the logical address into the corresponding physical address, or output "Page fault!". (7) Figure 1 explains the principle of converting a logical (virtual) addresse to the physical addresse. The values in the page table in the figure may be different from the values in the object page Table! Page table 10000000000100 15 000 0 14 000 0 13 000 0 12 000 0 11 111 1 10 000 0 9 101 1 8 000 0 000 0 000 0 011 1 4 100 1 3 000 1 2 110 1 1 001 1 0 010 1 7 6 5 110 -Present/ absent bit Virtual page = 2 is used as an index into the page table 12-bit offset copied directly from input to output 0010000000000100 Outgoing physical address (24580) Incoming virtual address (8196) Figure 1. Convert a logical address (virtual address) with 16 bits to the physical address. Please write a program in C++ to stimulate the internal operation of MMU with single-level page table. Description The virtual address is split into a virtual page number (high-order bits) and an offset (low-order bits). With a 16-bit address and a 4-KB page size, the upper 4 bits could specify one of the 16 virtual pages and the lower 12 bits would then specify the byte offset (0 to 4095) within the selected page. The virtual page number is used as an index into the page table to find the entry for that virtual page. From the page table entry, the page frame number (if any) is found. The page frame number is attached to the high-order end of the offset, replacing the virtual page number, to form a physical address that can be sent to the memory. Thus, the purpose of the page table is to map virtual pages onto page frames. Mathematically speaking, the page table is a function, with the virtual page number as argument and the physical frame number as result. Using the result of this function, the virtual page field in a virtual address can be replaced by a page frame field, thus forming a physical memory address. Notice (1) The page table is a single-level page table. (2) The related data structures and the global object pageTable were defined as follows, which can be accessed directly by your code. #define N 16 struct SPageTableEntry { }; unsigned char pageFramNr: 3; bool pa; struct SPageTable { SPageTableEntry pte[N]; SPageTable(); // constructor, already defined by the system to init pageTable. } pageTable; (3) You only need to write the main function in C++. (4) Don't return non-zero value in your main function, or it is regarded as a program error by the OJ system. (5) Input an unsigned short variable as a logical address. If the logical address is greater than 65535, then it is 65535. (6) Check the Present/absent bit, if it is 1, then convert the logical address into the corresponding physical address, or output "Page fault!". (7) Figure 1 explains the principle of converting a logical (virtual) addresse to the physical addresse. The values in the page table in the figure may be different from the values in the object page Table! Page table 10000000000100 15 000 0 14 000 0 13 000 0 12 000 0 11 111 1 10 000 0 9 101 1 8 000 0 000 0 000 0 011 1 4 100 1 3 000 1 2 110 1 1 001 1 0 010 1 7 6 5 110 -Present/ absent bit Virtual page = 2 is used as an index into the page table 12-bit offset copied directly from input to output 0010000000000100 Outgoing physical address (24580) Incoming virtual address (8196) Figure 1. Convert a logical address (virtual address) with 16 bits to the physical address. Please write a program in C++ to stimulate the internal operation of MMU with single-level page table. Description The virtual address is split into a virtual page number (high-order bits) and an offset (low-order bits). With a 16-bit address and a 4-KB page size, the upper 4 bits could specify one of the 16 virtual pages and the lower 12 bits would then specify the byte offset (0 to 4095) within the selected page. The virtual page number is used as an index into the page table to find the entry for that virtual page. From the page table entry, the page frame number (if any) is found. The page frame number is attached to the high-order end of the offset, replacing the virtual page number, to form a physical address that can be sent to the memory. Thus, the purpose of the page table is to map virtual pages onto page frames. Mathematically speaking, the page table is a function, with the virtual page number as argument and the physical frame number as result. Using the result of this function, the virtual page field in a virtual address can be replaced by a page frame field, thus forming a physical memory address. Notice (1) The page table is a single-level page table. (2) The related data structures and the global object pageTable were defined as follows, which can be accessed directly by your code. #define N 16 struct SPageTableEntry { }; unsigned char pageFramNr: 3; bool pa; struct SPageTable { SPageTableEntry pte[N]; SPageTable(); // constructor, already defined by the system to init pageTable. } pageTable; (3) You only need to write the main function in C++. (4) Don't return non-zero value in your main function, or it is regarded as a program error by the OJ system. (5) Input an unsigned short variable as a logical address. If the logical address is greater than 65535, then it is 65535. (6) Check the Present/absent bit, if it is 1, then convert the logical address into the corresponding physical address, or output "Page fault!". (7) Figure 1 explains the principle of converting a logical (virtual) addresse to the physical addresse. The values in the page table in the figure may be different from the values in the object page Table! Page table 10000000000100 15 000 0 14 000 0 13 000 0 12 000 0 11 111 1 10 000 0 9 101 1 8 000 0 000 0 000 0 011 1 4 100 1 3 000 1 2 110 1 1 001 1 0 010 1 7 6 5 110 -Present/ absent bit Virtual page = 2 is used as an index into the page table 12-bit offset copied directly from input to output 0010000000000100 Outgoing physical address (24580) Incoming virtual address (8196) Figure 1. Convert a logical address (virtual address) with 16 bits to the physical address.
Expert Answer:
Answer rating: 100% (QA)
C program that simulates the internal operation of an MMU with a singlelevel ... View the full answer
Related Book For
Operating Systems Design And Implementation
ISBN: 9780131429383
3rd Edition
Authors: Andrew Tanenbaum, Albert Woodhull
Posted Date:
Students also viewed these programming questions
-
Money (medium of exchange, unit of account, or store of value) is being used in each of the following examples. I am saving $80 per week to pay for my books next semester. I paid $85 for the digital...
-
Planning is one of the most important management functions in any business. A front office managers first step in planning should involve determine the departments goals. Planning also includes...
-
Managing Scope Changes Case Study Scope changes on a project can occur regardless of how well the project is planned or executed. Scope changes can be the result of something that was omitted during...
-
A car manufacturer designs a fuel-efficient car for 1993. The company argues that the car can attain an average of 45 miles per gallon. The miles per gallon of the car follows a normal distribution...
-
1. When a pair of dice is rolled, what is the probability that the sum of the dice is 8, given that the outcome is not 7? 2. When a pair of dice is rolled, what is the probability that the sum of the...
-
Refer to the table in Problem 3.8. In Problem 3.8, the City Commission of Nashville has decided to build a botanical garden and picnic area in the heart of the city for the recreation of its...
-
Tolerable error, a measure of the maximum monetary error that may exist in an account balance without causing materially misstated financial statements, is directly related to: a. Precision. b. Audit...
-
Tetra Company's cost system assigns MSDA expenses to customers using a rate of 33% of sales revenue. The new controller has discovered that Tetra's customers differ greatly in their ordering patterns...
-
You have a pool in your backyard that is 27 feet long by 14 feet wide that you would like to fill to a depth of 5.5 feet. How many cubic meters of water do you need to fill the pool? How many...
-
Sound Sleeper Ltd. manufactures and sells mattresses to retailers across Canada. In 2020, Sound Sleeper signed a two-year contract with Zzz Ltd. to supply it with 40,000 mattresses at a price of $100...
-
According to the Bathtub model: Et + U = L AUt+1=sEt- fUt What is the effect on steady state unemployment if the separation rate rises (s )? O The separation rate is always zero in steady state. O If...
-
Explain how a bank uses liability management to respond to a deposit outflow. Why do banks prefer liability management to asset management in this circumstance?
-
In response to changes in banking legislation, recent decades have seen a significant increase in interstate branching by banks in the United States. How do you think a development of this type would...
-
What is morality?
-
Money is an asset that is generally accepted in payment for goods and services or repayment of debts. a. Money has three basic uses: i. Means of payment ii. Unit of account iii. Store of value b....
-
Cyber risk has been recognized as a growing source of operational risk for financial institutions. Why might managing this risk at an individual firm level not be adequate?
-
Prove that J (2) = (~_n=x) J () + xJ__ () -x ntl where, Jn (x) is Bessef Polynomial function
-
Controls can be identified based on their function. The functions are preventive, detective, and corrective. A. True B. False
-
Disk controllers have internal buffers and they are getting larger with each new model. Why?
-
A computer has 1 GB of RAM allocated in units of 64 KB. How many KB are needed if a bitmap is used to keep track of free memory?
-
Show if setting the (now-unused) ROBUST flag might make the file system more or less robust in the face of a crash. Whether this is the case in the current version of MINIX 3 has not been researched,...
-
There are three general categories of capital budget scenarios: replacement, expansion, and investment in a NewCo. Describe the overall decision-making context for each. How do they draw on similar...
-
The overall process of creating a capital budget proposal has a lot of similarities to writing a business plan for a start-up company. Describe three aspects of the similarities between a budget...
-
In analysis, some focus seems to be on the need for NPV equations to be applied to projects that are mutually exclusive. But in practice we find that the lines are blurred in capital budgeting....
Study smarter with the SolutionInn App