What is 'the principle of locality'?- It is a term for the phenomenon in which the same values or related storage locations are frequently accessed.
- It is also known as the locality of reference.
- The next most data items or instruction is the closest to the current data item or instruction.
- For example, a block in a file may be the closest one that is needed next. The OS can read the next block before its need and made available it on hand at the time of issuing the actual read request.
There are two types of principle of locality:
1. Temporal locality 2. Spatial locality
- Principle of locality is the type of predictable behavior which occurs in computer systems.
- Programs tend to reuse the instructions they have used recently.
1.Temporal locality: - It refers to the reuse of specific data and resources.
2. Spatial locality: - It refers to the use of data elements within relatively close storage locations.
- Sequential locality is a special case of spatial locality which occurs when the data elements are arranged linearly, such as one-dimensional array.
|