header ads

Locality of Reference in OS - CodeTextPro

Concept of the locality of reference:
Locality of Reference in OS, Concept of locality of reference in Operating System.

In computer science, locality of reference, also called the principle of locality, is the term applied to situations where the same value or related storage locations are frequently accessed. Suppose a programmer began writing programs using block structures. The following constructs are blocked.

1. Compound statements 
2. Loops 
3. Functions 
4. Files.

If a block is a loop consisting of N statements, and if the loop executes 100 times, then for the next 100N instructions the control will remain within the loop.

The mechanism of keeping the program control confined to a block for the maximum time is called locality of reference. In this strategy, the program’s address space is divided into small blocks and each block is stored in contiguous pages. 

The advantage of this style of programming is that references become near and remain within a small block on a page.

The page fault frequency of a process depends upon whether the program was written using the principle of locality of reference. If the programmer has not followed the principle, then a very large number of page faults occur, and the phenomenon is called Thrashing.

Causes of thrashing: 

1. Unstructured program: 
In an unstructured program, the flow of control does not follow a well-structured path. The address references of operands are made to distant location situations in page s currently not available in the working set of processes. The ‘jump’ statements take control all over, within the variety of the program. So the no of page faults increased.

2. Over committed memory: 
If CPU utilization becomes low, then the degree of
multiprogramming is increased by swapping in processes from secondary memory. In this situation, too many processes are squeezed into little memory. If a large no of processes is present in the main memory, then it is difficult for the operating system to provide an adequate number of pages to the processes. And the CPU utilization falls further. If the memory is over committed to a large number of users, then systemic failure takes place.


Segmentation is a memory management technique in which each job is divided into several segments of different sizes, one for each module that contains pieces that perform related functions. Each segment is actually a different logical address space of the program.

When a process is to be executed, its corresponding segmentation is loaded into non-contiguous memory through every segment is loaded into a contiguous block of available memory.

Comparison Chart:

Locality of Reference in OS

Memory management functions:

Memory management concerned with the following functions. These are
1. Keeping track of memory
2. Determining factor on memory policy
3. Allocation and de-allocation of memory.

Post a Comment