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:


Question 2 (10-12 points)

A machine architecture supports the following type of virtual memory.

Answer the following questions:

Here are some useful Hex conversions:
ValueHex
10x1
20x2
40x4
80x8
160x10
320x20
640x40
1280x80
2560x100
5120x200
1K0x400
2K0x800
ValueHex
4K0x1000
8K0x2000
16K0x4000
32K0x8000
64K0x10000
128K0x20000
256K0x40000
512K0x80000
1M0x100000
2M0x200000
4M0x400000
8M0x800000
ValueHex
16M0x1000000
32M0x2000000
64M0x4000000
128M0x8000000
256M0x10000000
512M0x20000000
1G0x40000000
2G0x80000000
3K0xc00
5K0x1400
6K0x1800
10K0x2800
ValueHex
12K0x3000
24K0x6000
25K0x6400
48K0xc000
50K0xc800
96K0x18000
100K0x19000
200K0x32000
201K0x32400
202K0x32800
204K0x33000
208K0x34000

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.