Academic Integrity: tutoring, explanations, and feedback — we don’t complete graded work or submit on a student’s behalf.

You are writing a new 3D game that you hope will earn you fame and fortune. You

ID: 3862887 • Letter: Y

Question

You are writing a new 3D game that you hope will earn you fame and fortune. You are currently working on a function to blank the screen buffer before drawing the next frame. The screen you are working with is a 640 times 480 array of pixels. The machine you are working on has a 64 KB direct-mapped cache with 4-byte lines. The C structures you are using are as follows: struct pixel {char r; char g; char b; char a;}; struct pixel buffer[480] [640]; int i, j; char *cptr; int *iptr; Assume the following: sizeof(char) = 1 and sizeof(int) = 4. buffer begins at memory address 0. The cache is initially empty. The only memory accesses are to the entries of the array buffer. Variables i, j, cptr, and iptr are stored in registers. What percentage of writes in the following code will miss in the cache? for (j = 0; j

Explanation / Answer

solution--

See each initial write causes 4 bytes to be read so the next three are in-cache . So three out of four are in-cache which tells us that percentage of writes in the following code will miss in the cache will be 25%.

Hire Me For All Your Tutoring Needs
Integrity-first tutoring: clear explanations, guidance, and feedback.
Drop an Email at
drjack9650@gmail.com
Chat Now And Get Quote