Homework 4

**Credit:**- 35 points.

Be sure you have read, or at least skimmed, sections 1 through 3 of Chapter 3.

Please include with each part of the assignment the Honor Code pledge or
just the word ``pledged'', plus one or more of the following about
collaboration and help (as many as apply).^{1}Text *in italics* is explanatory or something for you to
fill in.
For written assignments, it should go right after your name and
the assignment number; for programming assignments, it should go
in comments at the start of your program(s).

- This assignment is entirely my own work.
*(Here, ``entirely my own work'' means that it's your own work except for anything you got from the assignment itself -- some programming assignments include ``starter code'', for example -- or from the course Web site. In particular, for programming assignments you can copy freely from anything on the ``sample programs page''.)* - I worked with
*names of other students*on this assignment. - I got help with this assignment from
*source of help -- ACM tutoring, another student in the course, the instructor, etc.**(Here, ``help'' means significant help, beyond a little assistance with tools or compiler errors.)* - I got help from
*outside source -- a book other than the textbook (give title and author), a Web site (give its URL), etc.*.*(Here too, you only need to mention significant help -- you don't need to tell me that you looked up an error message on the Web, but if you found an algorithm or a code sketch, tell me about that.)* - I provided help to
*names of students*on this assignment.*(And here too, you only need to tell me about significant help.)*

Answer the following questions. You may write out your answers by hand or using a word processor or other program, but please submit hard copy, either in class or in one of my mailboxes (outside my office or in the ASO).

- (5 points)
Consider a computer system with 10,000 bytes of memory
whose MMU uses the simple base register / limit register scheme
described in section 3.2 of the textbook,
and suppose memory is currently allocated as follows:
- Locations 0-1999 are reserved for use by the operating system.
- Process occupies locations 5000-6999.
- Process occupies locations 7000-8999.
- Other locations are free.

Answer the following questions about this system.

- What value would need to be loaded into the base
register if we performed a context switch
to restart process
?
- What memory locations would correspond to
the following virtual (program)
addresses in process
?
- 100
- 4000

- 100

- (15 points)
Consider a computer system using paging to manage
memory; suppose it has 64K (
) bytes of
memory and a page size of 4K bytes, and
suppose the page table for some process (call it process
)
looks like the following.
Page number Present/absent bit Page frame number 0 1 5 1 1 6 2 1 2 3 0 ? 4 0 ? 5 1 7 6 0 ? ... 0 ? 15 0 ? Answer the following questions about this system.

- How many bits are required to represent a physical
address (memory location) on this system?
If each process has a maximum address space of
64K bytes, how many bits are required to
represent a virtual (program) address?
- What memory locations would correspond to the
following virtual (program) addresses for process
?
(Here, the addresses will be given in
hexadecimal, i.e., base 16, to make the needed
calculations simpler. Your answers should also
be in hexadecimal. Notice that if you find yourself
converting between decimal and hexadecimal,
*you are doing the problem the hard way*. Stop and think whether there is an easier way!)- 0x1420
- 0x2ff0
- 0x4008
- 0x0010

- 0x1420
- If we want to guarantee that this system could
support 16 concurrent processes and give each
an address space of 64K bytes, how much disk
space would be required for storing out-of-memory
pages? Explain your answer (i.e., show/explain how
you calculated it).
Assume that the first page frame is always
in use by the operating system and will never be
paged out. You may want to make additional assumptions;
if you do, say what they are.

- How many bits are required to represent a physical
address (memory location) on this system?
If each process has a maximum address space of
64K bytes, how many bits are required to
represent a virtual (program) address?
- (15 points)
Now consider a bigger computer system,
one in which addresses (both physical and virtual) are 32 bits
and the system has
bytes of memory.
Answer the following questions about this system.
(You can express your answers in terms of powers of 2,
if that is convenient.)
- What is the maximum size in bytes of a process's address
space on this system?
- Is there a logical
limit to how much main memory this system
can make use of? That is, could we buy and install
as much more memory as we like, assuming no hardware
constraints? (Assume that the sizes of physical
and virtual addresses don't change.)
- If page size is 4K (
) and each page table
entry consists of a page frame number and four
additional bits (present/absent, referenced,
modified, and read-only), how much space is required
for each process's page table?
(You should express the size of each page table
entry in bytes, not bits, assuming 8 bits per byte
and rounding up if necessary.)
- Suppose instead the system uses a single inverted page table
(as described in section 3.3.4 of the textbook),
in which each entry consists of
a page number, a process ID,
and four additional bits (free/in-use, referenced,
modified, and read-only), and at most
64 processes are allowed.
How much space is needed for this
inverted page table?
(You should express the size of each page table
entry in bytes, not bits, assuming 8 bits per byte
and rounding up if necessary.)
How does this compare to the amount of space
needed for 64 regular page tables?

- What is the maximum size in bytes of a process's address
space on this system?

- ... apply).
^{1} - Credit where credit is due: I based the wording of this list on a posting to a SIGCSE mailing list. SIGCSE is the ACM's Special Interest Group on CS Education.

2017-10-18