Caches 20 points 1 Consider a machine with a direct mapped cache that has 8

Caches 20 points 1 consider a machine with a direct

This preview shows page 14 - 19 out of 20 pages.

Problem 5: Caches (20 points)1. Consider a machine with a direct mapped cache that has 8-sets and has a block size of 4-bytes.Memory addresses are 13-bits and each memory access from a processor requests a byte from thecache. The contents of the cache are as follows, with all numbers in hexadecimal.Cache LineSet IndexTagValidByte 0Byte 1Byte 2Byte 3009130F472AB1381783F92D426E0----30601FDA40C54C71----5711D39A0B126911----74605C80B359(a) (2 points) Calculate the size of the cache in bytes.(b) (3 points) Indicate the number of bits used to determinethe block offset:set index:tag:(c) (10 points) A program running on this machine makes memory references at the addressesspecified in the first column of the following table. For each memory reference indicate whatis the block offset, set index and tag. Furthermore, indicate whether a cache hit occurs and thebyte returned. The byte returned is - for a miss. Address Set index Block offset Tag Cache hit? (Y/N) Byte returned 0x0E35 0x0DD5 0x1FE4 0x0705 14
Image of page 14
(d) (3 points) If we redesign the cache by increasing the associativity to 4 while keeping the totalcache size exactly the same as above, how many bits will you use for the following:Tag:Set index:Block offset:(e) (2 points) What is spatial locality and temporal locality? 15
Image of page 15
A B C A B C A B C Figure 2: Examples of cycles for a linked list with 3 nodes. Extra Credit Questions Extra Credit 1: C Programming (15 points) You are given a pointer to a singly linked list. The singly linked list has cycles due to a programming error. Write a C program to detect whether the linked list has cycles without storing all the pointers to the nodes . The function detect_cycles should return 1 when a cycle is found and 0 when there are no cycles. Your code should handle all corner cases carefully and should not cause segmentation fault. Figure shows various examples of cycles for a list with 3 nodes. The number of nodes in the input list can range from 0 to a billion nodes. struct node{ void* data; struct node* next; }; int detect_cycles(struct node* list){ 16
Image of page 16
/* another page for work */ 17
Image of page 17
Image of page 18
Image of page 19

  • Left Quote Icon

    Student Picture

  • Left Quote Icon

    Student Picture

  • Left Quote Icon

    Student Picture