What is temporal locality and spatial locality?
There are two basic types of reference locality – temporal and spatial locality. Temporal locality refers to the reuse of specific data and/or resources within a relatively small time duration. Spatial locality (also termed data locality) refers to the use of data elements within relatively close storage locations.
What is spatial and temporal locality give an example of each?
The outer loop is an example of spacial locality. It sequentially increments the address the inner for-loop calls. The inside loop demonstrates temporal locality. The exact same memory address is accessed ten times in a row, and multiplied by j each time.
What is the principle of locality explain how caches take advantage of temporal and spatial locality?
— The principle of temporal locality says that if a program accesses one memory address, there is a good chance that it will access the same address again. — The principle of spatial locality says that if a program accesses one memory address, there is a good chance that it will also access other nearby addresses.
Can a program have both spatial and temporal locality?
Code fragments such as loops exhibit both temporal and spatial locality. Programs often access data that is stored contiguously.
How is temporal locality exploited in computer?
Temporal locality is exploited by having a cache between the proces- sor and the memory that is big enough so that a word gets accessed multiple times before getting evicted. Spatial lo- cality is exploited by using blocks spanning multiple words to move data between the different layers of the hierarchy.
How do you exploit spatial locality?
To exploit spatial locality, a cache uses larger blocks to hold several consecutive words. The advantage of a block size greater than one is that when a miss occurs and the word is fetched into the cache, the adjacent words in the block are also fetched.
How is spatial locality exploited?
Which of the following data exhibits spatial locality?
Explanation: In computer language, an array is for of particular data arranged in a column. It displays information of different frequency in a very coherent manner.