Question

Please use the python to write Assume that a system has a 32-bit virtual address with...

Please use the python to write

Assume that a system has a 32-bit virtual address with a 4-KB page size. Write a
program that is passed a virtual address (in decimal) on the command line and have it
output the page number and offset for the given address. As an example, your program
would run as follows:
./addresses 19986
Your program would output:
The address 19986 contains:
page number = 4
offset = 3602
Writing this program will require using the appropriate data type to store 32 bits. We
encourage you to use unsigned data types as well. For python please use the ctype
ctypes.c_uint32.

0 0
Add a comment Improve this question Transcribed image text
Answer #1
import sys
import ctypes

n = int(sys.argv[1])

print("The address {} contains:\npage number = {}\noffset = {}".format(n, n // 4096, n % 4096))
Add a comment
Know the answer?
Add Answer to:
Please use the python to write Assume that a system has a 32-bit virtual address with...
Your Answer:

Post as a guest

Your Name:

What's your source?

Earn Coins

Coins can be redeemed for fabulous gifts.

Not the answer you're looking for? Ask your own homework help question. Our experts will answer your question WITHIN MINUTES for Free.
Similar Homework Help Questions
  • In C++ l. Assume that a system has a 32-bit virtual address with a 4-KB page...

    In C++ l. Assume that a system has a 32-bit virtual address with a 4-KB page size. Write a program that is passed a virtual address (in decimal) on the command line and have it output the page number and offset for the given address. As an example, your program would run as follows: yourprogram 19986 Your program would output: The address 19986 contains: Page number = 4 Offset = 3602 Writing this program will require using the appropriate data...

  • Please give me all necessary screenshot and comments. (I use Eclipse) Thanks Assume a system has...

    Please give me all necessary screenshot and comments. (I use Eclipse) Thanks Assume a system has 32-bit virtual memory address with a 4-KB page size. Write a program that is passed a virtual address (in decimal) and outputs the page number and offset for the given address. The output should look like: The address 19986 contains:       Page number = 4       Offset = 3602 Your driver should pass the program three numbers: 19986, 347892, and 5978. Note the program...

  • Consider a virtual memory system with the following properties: 36 bit virtual byte address, 8 KB...

    Consider a virtual memory system with the following properties: 36 bit virtual byte address, 8 KB pages size, and 32 bit physical byte address. Please explain how you determined your answer. a. What is the size of main memory for this system if all addressable frames are used? b. What is the total size of the page table for each process on this processor, assuming that the valid, protection, dirty, and use bits take a total of 4 bits and...

  • 17. A computer system implements a paged virtual memory system. Assume a 16-bit virtual address space...

    17. A computer system implements a paged virtual memory system. Assume a 16-bit virtual address space and a 24-bit physical address space. Assume that the first 6 bits of a virtual address index the page table and the rest of the bits are the page offset. A process has the following indexed page table. Index Page Table Entry (PTE) 0x3800 0x3600 0x3200 0x1000 2 3 Each page table entry qives a hexadecimal page frame addresses. Translate the following two hexadecimal...

  • The RISC-V 32-bit architecture supports virtual memory with 32-bit virtual addresses mapping to 32-bit physical addresse...

    The RISC-V 32-bit architecture supports virtual memory with 32-bit virtual addresses mapping to 32-bit physical addresses. The page size is 4Kbytes, and page table entries (PTEs) are 4 bytes each. Translation is performed using a 2-level page table structure. Bits 31:22 of a virtual address index the first-level page table. If the selected first-level PTE is valid, it points to a second-level page table. Bits 21:12 of the virtual address then index that second-level page table. If the selected second-level...

  • 1) Given a virtual memory system with: virtual address 36 bits physical address 32 bits 32KB...

    1) Given a virtual memory system with: virtual address 36 bits physical address 32 bits 32KB pages (15 bit page offset) Each page table entry has bits for valid, execute, read and dirty (4 bits total) and bits for a physical page number. a) How many bits in the page table? (do not answer in bytes!) Three digit accuracy is good enough. The exponent may be either a power of 2 or a power of 10. b) The virtual address...

  • it’s from operating system. please provide me correct answer. A computer has 32-bit virtual addresses and...

    it’s from operating system. please provide me correct answer. A computer has 32-bit virtual addresses and 4-KB pages. The program and data together fit in the lowest page (0-4095) The stack fits in the highest page. How many entries are needed in the page table if traditional (one-level) paging is used? How many page table entries are needed for two-level paging, with 10 bits in each part? Submission: Upload a document with your calculations and results

  • Given a virtual memory configuration with: • 4 TB virtual memory space • 32 GB physical...

    Given a virtual memory configuration with: • 4 TB virtual memory space • 32 GB physical memory space • 16 KB page size How many bits are needed for the virtual address? Choose... How many bits are needed for the physical address? Choose... How many bits in the address correspond to page offset bits? Choose... - How many bits will the virtual page number (VPN) be? Choose... - How many bits will the physical page number (PPN) be? Choose... →...

  • A computer has 32-bit virtual addresses and the page size is 2^3 KB. Suppose the text,...

    A computer has 32-bit virtual addresses and the page size is 2^3 KB. Suppose the text, data, and stack segments of a process need 5 page(s) each. If the computer uses two-level page tables, with 3 bits for the second-level index, how many page table entries (PTEs) are in each second-level page table?

  • Write a Java program that prompts the user for the page size used in a virtual...

    Write a Java program that prompts the user for the page size used in a virtual memory system; this will be a power of two between 512 (29) and 16384 (214), inclusive. Your program should check the user input for page size to make sure it is one of the allowable inputs (must be a power of 2 and cannot be smaller than 512 or larger than 16384), and should then prompt the user for a virtual address (assume 32-bit...

ADVERTISEMENT
Free Homework Help App
Download From Google Play
Scan Your Homework
to Get Instant Free Answers
Need Online Homework Help?
Ask a Question
Get Answers For Free
Most questions answered within 3 hours.
ADVERTISEMENT
ADVERTISEMENT
ADVERTISEMENT