Prerequisite – Locality of Reference
1. Spatial Locality :
Spatial Locality means that all those instructions which are stored nearby to the recently executed instruction have high chances of execution. It refers to the use of data elements(instructions) which are relatively close in storage locations.
2. Temporal Locality :
Temporal Locality means that a instruction which is recently executed have high chances of execution again. So the instruction is kept in cache memory such that it can be fetched easily and takes no time in searching for the same instruction.
Difference between Spatial Locality and Temporal Locality :
|S.No.||Spatial Locality||Temporal Locality|
|1.||In Spatial Locality, nearby instructions to recently executed instruction are likely to be executed soon.||In Temporal Locality, a recently executed instruction is likely to be executed again very soon.|
|2.||It refers to the tendency of execution which involve a number of memory locations .||It refers to the tendency of execution where memory location that have been used recently have a access.|
|3.||It is also known as locality in space.||It is also known as locality in time.|
|4.||It only refers to data item which are closed together in memory.||It repeatedly refers to same data in short time span.|
|5.||Each time new data comes into execution.||Each time same useful data comes into execution.|
Data elements accessed in array (where each time different (or just next) element is being accessing ).
Data elements accessed in loops (where same data elements are accessed multiple times).
Attention reader! Don’t stop learning now. Get hold of all the important CS Theory concepts for SDE interviews with the CS Theory Course at a student-friendly price and become industry ready.
- Difference between Spatial and Temporal Data Mining
- Computer Organization | Locality and Cache friendly code
- Locality of Reference and Cache Operation in Cache Memory
- Difference between Stop and Wait, GoBackN and Selective Repeat
- Difference between Stop and Wait protocol and Sliding Window protocol
- Similarities and Difference between Java and C++
- Difference between Yaacomo and and XAP
- Difference between VoIP and and POTS
- Difference and Similarities between PHP and C
- Difference between Time Tracking and Time and Attendance Software
- Difference Between Single and Double Quotes in Shell Script and Linux
- Difference between ++*p, *p++ and *++p
- Difference Between DOS and Windows
- Difference between User Level thread and Kernel Level thread
- What’s difference between The Internet and The Web ?
- Difference between Priority Inversion and Priority Inheritance
- What’s difference between Linux and Android ?
- What’s difference between header files "stdio.h" and "stdlib.h" ?
- Difference between HTML and HTTP
- Difference between http:// and https://
If you like GeeksforGeeks and would like to contribute, you can also write an article using contribute.geeksforgeeks.org or mail your article to firstname.lastname@example.org. See your article appearing on the GeeksforGeeks main page and help other Geeks.
Please Improve this article if you find anything incorrect by clicking on the "Improve Article" button below.