Homework 5
Due 9/28/2011 3:59PM
Problem 1
Given the following program that uses
three
memory segments in an address space as described in class (code
segment,
data segment ,and stack segment):
char
a[100];
main(int
argc, char **
argv)
{
int
d;
staticdouble
b;
char *s
= "boo", * p;
p = malloc(300);
return
0;
}
Identify the segment in which each variable
resides
and indicate if the variable is private to the thread or is
shared among
threads.
Be careful.
Problem 2
This question refers to an architecture using segmentation with
paging (you may need to consult the text for details).
In this architecture, the 32-bit virtual address is divided into
fields
as follows:
4 bit segment number |
12 bit page number |
16 bit offset |
Here are the relevant tables (all values in hexadecimal):
Segment Table | |
Page Table A | |
Page Table B |
0 | Page Table A | |
0 | CAFE | |
0 | F000 |
1 | Page Table B | |
1 | DEAD | |
1 | D8BF |
x | (rest invalid) | |
2 | BEEF | |
x | (rest invalid) |
| | |
3 | BA11 |
| | |
| | |
x | (rest invalid) |
| | |
Find the physical address corresponding to each of the
following
virtual addresses (answer "bad virtual address" if the
virtual address is invalid):
- 00000000
- 20022002
- 10015555
Problem 3
In a 32-bit machine we subdivide the virtual address
into 4 segments as follows:
We use a 3-level page table, such that the first
10-bit are for the first level and so on.
-
What is the page size in such a system?
-
What is the size of a page table for a process
that has 256K of memory starting at address 0?
-
What is the size of a page table for a process
that has a code segment of 48K starting at address 0x1000000, a data
segment
of 600K starting at address 0x80000000 and a stack segment of 64K
starting
at address 0xf0000000 and growing upward (like in the PA-RISC of
HP)?
Problem 4
In a 32-bit machine we subdivide the virtual address into 4 pieces as follows:
8-bit 4-bit 8-bit 12-bit
We use a 3-level page table, such that the first 8 bits are for the first level
and so on. Physical addresses are 44 bits and there are 4 protection bits per
page.
-
What is the page size in such a system?
-
How much memory is consumed by the page
table and wasted by internal fragmentation for a process that has
64K of memory
starting at address 0?
-
How much memory is consumed by the page
table and wasted by internal fragmentation for a process that has a
code
segment of 48K starting at address 0x1000000, a data segment of 600K
starting
at address 0x80000000 and a stack segment of 64K starting at address
0xf0000000
and growing upward (towards higher addresses)?
Problem 5
Consider a system with a virtual address size of 64MB (2^26),
a physical memory of size 2GB (2^31), and a page size of 1K (2^10).
Under the target workload, 32 processes (2^5) are running;
half of the processes are smaller than 8K (2^13) and half use the full
64MB virtual address space. Each page has 4 control bits.
- What is the size of a single top-level page table entry (and why)?
- What is the size of a single bottom-level page table entry (and why)?
- If you had to choose between two arrangements of page table:
2-level and 3-level, which would you choose and why?
Compute the expected space overhead for each variation: State the
space overhead for each small process and each large process.
Then compute the total space overhead for the entire system.