Final Raw
Final Raw
Instructions:
Make sure that your exam is not missing any sheets, then write your full name on the front.
Write your answers in the space provided below the problem. If you make a mess, clearly
indicate your final answer.
The problems are of varying difficulty. The point value of each problem is indicated. Pile
up the easy points quickly and then come back to the harder problems
Using the templates below (allowing a maximum of 24 bytes), indicate the allocation of data for
structs of type OldSensorData NewSensorData. Mark off and label the areas for each individual
element(arrays may be labeled as a single element). Cross hatch the parts that are allocated, but
not used (to satisfy alignment). Assume the Linux alignment rules discussed in class. Clearly
indicate the right hand boundary of the data structure with a vertical line.
OldSensorData:
0 1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23
c[2]
long c[0] c[1] short int[0] int[1]
NewSensorData:
0 1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23
c[1] c[3]
c[0] s[0] s[1] flo double
c[2] c[4] at
For example:
0 1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23
Problem 2 (20pts).
Consider the source code below, where M and N are constants declared with #define.
int mat1[M][N];
int mat2[N][M];
int sum_element(int i, int j)
{
return mat1[i][j] + mat2[i][j];
}
.......................................................................................................................................................
.......................................................................................................................................................
.......................................................................................................................................................
00000000000006c2 <main>:
6c2: 48 83 ec 08 sub $0x8,%rsp
6c6: bf 03 00 00 00 mov $0x3,%edi
6cb: b8 00 00 00 00 mov $0x0,%eax
6d0: e8 95 ff ff ff callq 66a <foo>
6d5: 48 98 cltq
6d7: 48 83 c4 08 add $0x8,%rsp
6db: c3 retq
6dc: 0f 1f 40 00 nopl 0x0(%rax)
To help you get started, we have given you the first two rows.
Write the actual values (for example: 1 instead of %eax), or Unused
Before calling foo
- The address of %rsp = 0x7FFFFFFFDE88,
- The return address in main function called foo = 0x6d5
0x7FFFFFFFDE70 Unused
0x7FFFFFFFDE68 0x7
0x7FFFFFFFDE60
0x5
0x7FFFFFFFDE58
0x3
0x7FFFFFFFDE50 0x2
Short explantation
.......................................................................................................................................................
.......................................................................................................................................................
.......................................................................................................................................................
.......................................................................................................................................................
Problem 4 (20pts).
The following table gives the parameters for a number of different caches, where m is the number
of physical address bits, C is the cache size (number of data bytes), B is the block size in bytes,
and E is the number of lines per set. For each cache, determine the number of cache sets (S), tag
bits (t), set index bits (s), and block offset bits (b).
Cache m C B E S t s b
1. 32 2048 8 1 256 21 8 3
2. 32 4 2
3. 32 2048 4 4 128 23 7 2
4. 32 1024 8 25 6 1
2 64
5. 32 32 16 23 4 5
1024 2
.......................................................................................................................................................
.......................................................................................................................................................
.......................................................................................................................................................
.......................................................................................................................................................
0 09 1 86 30 3F 10 00 0 99 04 03 48
1 45 1 60 4F E0 23 38 1 00 BC 0B 37
2 EB 0 2F 81 FD 09 0B 0 8F E2 05 BD
3 06 0 3D 94 9B F7 32 1 12 08 7B AD
4 C7 1 06 78 07 C5 05 1 40 67 C2 3B
5 71 1 0B DE 18 4B 6E 0 B0 39 D3 F7
6 91 1 A0 B7 26 2D F0 0 0C 71 40 10
7 46 0 B1 0A 32 0F DE 1 12 88 88 37
The box below shows the format of a physical address. Indicate (by labeling the diagram) the fields
that would be used to determine the following:
CO The block offset within the cache line
CI The cache index
CT The cache tag
CT CT CT CT CT CT CT CT CI CI CO CO
CI
12 11 10 9 8 7 6 5 4 3 2 1 0
For the given physical address, indicate the cache entry accessed and the cache byte value returned in hex.
Indicate whether a cache miss occurs. If there is a cache miss, enter “-” for “Cache Byte returned”.
Short explanation
.......................................................................................................................................................
.......................................................................................................................................................
.......................................................................................................................................................
.......................................................................................................................................................