CS560 Final Exam - May 4, 2005
Jim Plank
Question 1 (8-12 points)
Explain in detail what a File Allocation Table is.
In your explanation, include the following details:
- How are files organized?
- What metadata is needed for the operating system to find the bytes
of a file?
- How are the blocks on the disk organized and maintained?
- Discuss caching in such a system -- what kinds of caching would be
beneficial?
Question 2 (10-12 points)
A machine architecture supports the following type of virtual memory.
- Pointers are four bytes.
- Pages are 8K.
- There are four segments.
- Each segment is represented by two registers - a segment table
base register (STBR) and a segment table length register(STLR).
These point to the single-level page tables for each segment.
- Each PTE takes 4 bytes, and is composed of a 27-bit pointer, plus
five bits: used, dirty, read, write, execute.
Answer the following questions:
- A: How many pages can there possibly be in a segment (do not include
the page table as part of this -- just the memory in the segments)? You may
express your answer as a power of two.
- B: How many pages can there possibly be in a segment's page table?
Again, you may express your answer as a power of two. (In this question, I mean
how many pages compose the memory used by the segment's page table, not
the number of PTE's).
- C: Suppose a program is executing, and at a certain point in time,
it has the following sizes of its memory regions:
- Code: 200K
- Globals: 24K
- Heap: 8M
- Stack: 64K
Suppose page 0 of virtual memory is invalid. Moreover, suppose
each of these regions is stored in a different segment.
Show how the virtual address space of the program is partitioned.
(e.g. something like "addresses 0 to 54ff are invalid; addresses 0x5500 to 0x5fff correspond to the XX
segment; addresses 0x6000 to 0x10fff are invalid, etc.")
- D: Given the scenario for C above, how many pages of memory
will be used to store the process's page tables?
Here are some useful Hex conversions:
Value | Hex |
1 | 0x1 |
2 | 0x2 |
4 | 0x4 |
8 | 0x8 |
16 | 0x10 |
32 | 0x20 |
64 | 0x40 |
128 | 0x80 |
256 | 0x100 |
512 | 0x200 |
1K | 0x400 |
2K | 0x800 |
|
|
Value | Hex |
4K | 0x1000 |
8K | 0x2000 |
16K | 0x4000 |
32K | 0x8000 |
64K | 0x10000 |
128K | 0x20000 |
256K | 0x40000 |
512K | 0x80000 |
1M | 0x100000 |
2M | 0x200000 |
4M | 0x400000 |
8M | 0x800000 |
|
|
Value | Hex |
16M | 0x1000000 |
32M | 0x2000000 |
64M | 0x4000000 |
128M | 0x8000000 |
256M | 0x10000000 |
512M | 0x20000000 |
1G | 0x40000000 |
2G | 0x80000000 |
3K | 0xc00 |
5K | 0x1400 |
6K | 0x1800 |
10K | 0x2800 |
|
|
Value | Hex |
12K | 0x3000 |
24K | 0x6000 |
25K | 0x6400 |
48K | 0xc000 |
50K | 0xc800 |
96K | 0x18000 |
100K | 0x19000 |
200K | 0x32000 |
201K | 0x32400 |
202K | 0x32800 |
204K | 0x33000 |
208K | 0x34000 |
|
Question 3 (7-10 points)
Here's an excerpt form the man page for gets():
char *gets(char *s);
gets() reads a line from stdin into the buffer pointed to by s until
either a terminating newline or EOF, which it replaces with the
NULL character (0).
Explain how using gets() exposes one to a buffer overflow attack,
and explain exactly how the attack is implemented. Draw before and
after pictures of the relevant parts of memory.
Question 4 (4-7 points)
Suppose we have 4 data words, and we want to calculate 6 coding
words such that if we have any 4 of the 10 data+coding words, we
can reconstruct the 4 data words.
Outline how Reed-Solomon is used to achieve this. Explain what is involved in
encoding, and what is involved in decoding.
Question 5 (15 - 20 points)
In this question do not forget the stack and code
segments!!. Also, remember that doubles are 8 bytes.
Here is a piece of code that does matrix multiplication on
two square matrices. A matrix with n rows and n
columns is represented by an array a, which has n*n
elements. The element in the i-th row and the j-th
column is in a[i*n+j] (obviously, we are using standard
zero-indexing). Mmult() multiplies matrices a
and b and puts the result into c:
mmult(double *a, double *b, double *c, int n)
{
int i, j, k;
for (i = 0; i < n; i++) { /* Loop 1 */
for (j = 0; j < n; j++) { /* Loop 2 */
c[i*n+j] = 0;
for (k = 0; k < n; k++) { /* Loop 3 */
c[i*n+j] += (a[i*n+k] * b[k*n+j]);
}
}
}
}
Suppose a, b and c are all aligned on
page boundaries, and that pages are 8K.
Part 1
How many pages are touched (read/written) on an iteration
of Loop 3 when n = 10? (by an iteration, I mean
the entire execution of the loop "for (k = 0; ..."). Perhaps
that's not well stated. Sorry.
Part 2
How many pages are touched (read/written) on an iteration
of Loop 3 when n = 1024?? You may want to explain
how you get your answer.
Part 3
Let your answer to part 2 be x. What is the
the minimum number of pages that need to be allocated
to your process so that an iteration of Loop 3 has at most
x page faults if an LRU page replacement policy is adopted?
Explain how you derived your answer.
Part 4
Answer part 3 if a FIFO page replacement policy is
adopted. Again, explain how you derived your answer.
Part 5
Can the FIFO page replacement policy be augmented so that you
if you use roughly the number of pages that you used in part 3,
you will have a lot of page faults, but the overall performance of
the VM system will be close to that of part 3? Explain.