CSCI 4320 (Principles of Operating Systems), Fall 2003:
Homework 4
- Assigned:
- November 4, 2003.
- Due:
- November 11, 2003, at 5pm.
- Credit:
- 40 points.
Be sure you have read chapter 4.
Problems
Do the following problems.
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 my mailbox in the department office.
- (6 points)
Consider a computer system that uses variable partitions
and swapping to manage memory
(as described in chapter 4 pages 197-198);
suppose it has 10,000 bytes of main memory,
currently allocated as shown by the following table.
(In this problem, amounts and addresses are in decimal,
and unrealistically small, to keep the arithmetic simple.)
Locations |
Contents |
7500 - 9999 |
free |
4500 - 7499 |
process |
4000 - 4499 |
free |
3000 - 3999 |
process |
2000 - 2999 |
free |
0 - 1999 |
operating system |
Answer the following questions:
- Suppose we now need to allocate space
first for process , which needs 400 bytes,
and then for process , which needs 200 bytes.
At what addresses (locations) will memory
be allocated for these two processes if we use
- a best-fit strategy for allocating memory?
- a worst-fit strategy for allocating memory?
- a first-fit strategy for allocating memory?
- Suppose the MMU for this system uses the simple
base register / limit register scheme
described in chapter 1 of the textbook
(pages 26-27).
- 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 ?
- (10 points)
Now 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 |
4 |
2 |
1 |
2 |
3 |
0 |
? |
4 |
0 |
? |
5 |
1 |
7 |
Answer the following questions about this system.
- If the only processes in main memory were process
and an operating system using page frame 0,
how many free page frames would there be?
- How many additional page table entries would be
required to give process an address space
of 64K bytes?
- How many bits are required to represent physical
addresses (memory locations) on this system?
If each process has a maximum address space of
64K bytes, how many bits are required to
represent virtual (program) addresses?
- 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
- 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? Justify your answer.
(If your answer depends on making additional
assumptions, state what they are -- e.g.,
you might assume that
the operating system will always
use the first page frame of memory and will never
be paged out.)
- Would it be possible on this system to give each
process a maximum address space of 1M ()
bytes? Briefly explain your answer.
- (6 points)
Consider a small computer system with only four page frames
and address spaces consisting of eight pages.
Suppose we start out with all page frames empty
(pure demand paging) and run a program that references
pages in the following order:
(That is, its first reference to memory is in page number 0,
its second reference to memory is in page number 1, etc.)
If FIFO page replacement is being used, how many page
faults will occur during the running of this program?
- (6 points)
Consider another small computer system with only four
page frames. Suppose you have implemented the aging
algorithm for page replacement, using 4-bit counters
and updating the counters after every clock tick,
and suppose the bits for the four pages are as
follows after the first four clock ticks.
Time |
bit (page 0) |
bit (page 1) |
bit (page 2) |
bit (page 3) |
after tick 1 |
0 |
1 |
1 |
1 |
after tick 2 |
1 |
0 |
1 |
0 |
after tick 3 |
1 |
0 |
1 |
1 |
after tick 4 |
1 |
1 |
0 |
1 |
What are the values of the counters (in binary)
for all pages after these four clock ticks?
If a page needed to be removed at that point,
which page would be chosen for removal?
- (8 points)
Now consider a much bigger computer system,
one in which addresses (both physical and virtual) are 32 bits
and the system has bytes of memory.
(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?
- 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?
If we allow a maximum of 64 () processes,
how much space in total is required for
all their page tables?
(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 we use a single inverted page table
(as described in chapter 4, pages 213-214),
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 we allow at most
64 processes, 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.)
- (4 points)
A particular system using demand paging and observed to
be running slowly is monitored. It is discovered that
the CPU is in use about 20% of the time, the paging disk
is in use about 98% of the time, and other disks are in
use about 5% of the time. For each of the following,
say whether it would be likely to increase CPU utilization
and why.
- Installing a faster CPU.
- Installing a larger paging disk.
- Increasing the number of processes (degree of
multiprogramming).
- Decreasing the number of processes (degree of
multiprogramming).
- Installing more main memory.
- Installing a faster paging disk.
Berna Massingill
2003-11-04