Docsity
Docsity

Prepare for your exams
Prepare for your exams

Study with the several resources on Docsity


Earn points to download
Earn points to download

Earn points by helping other students or get them with a premium plan


Guidelines and tips
Guidelines and tips

Locality of Reference in Computer Science, Study notes of Operating Systems

The concept of locality of reference in computer science, which refers to frequently accessing the same value or related storage locations. It also discusses the advantages of programming using block structures and the phenomenon of thrashing, which occurs when a program does not follow the principle of locality of reference. Additionally, the document introduces the memory management technique of segmentation.

Typology: Study notes

2016/2017

Available from 03/10/2023

subhrajit-chakraborty
subhrajit-chakraborty 🇮🇳

5 documents

1 / 4

Toggle sidebar

This page cannot be seen from the preview

Don't miss anything!

bg1
Concept of locality of reference:
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 programmers began writing programs using block structures. Following constructs are
block.
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 next
100N instructions the control will remain within the loop.
The mechanism of keeping the program control confined to a block for maximum time is called
locality of reference. In this strategy, the program’s address space is divided into small blocks
and each blocks are 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.
Thrashing:
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 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 situation in page
s currently not available in working set of process. The jump statements take a control all over,
within the various of the program. So the no of page faults increased.
pf3
pf4

Partial preview of the text

Download Locality of Reference in Computer Science and more Study notes Operating Systems in PDF only on Docsity!

Concept of locality of reference:

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 programmers began writing programs using block structures. Following constructs are block.

  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 next 100N instructions the control will remain within the loop.

The mechanism of keeping the program control confined to a block for maximum time is called locality of reference. In this strategy, the program’s address space is divided into small blocks and each blocks are 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.

Thrashing:

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 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 situation in page s currently not available in working set of process. The ‘jump’ statements take a control all over, within the various 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 are present in main memory, then it is difficult for the operating system to provide 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

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 are loaded into non-contiguous memory though every segment is loaded into a contiguous block of available memory.

Memory management functions:

Memory management concerned with following functions. These are

  1. Keeping track of memory
  2. Determining factor on memory policy
  3. Allocation and de allocation of memory.