Download as docx, pdf, or txt
Download as docx, pdf, or txt
You are on page 1of 14

A

Micro-Project Report
On

“Develop a program to calculate page


fault for given page reference string by
using different page replacement
Submitted for the partial fulfillment of Fifth Semester subject
“OPERATING SYSTEM” code: 22516.

Submitted By:-
Name of Student Enrollment No.

Under the Guidance of

Mr. J M Meshram
Head of Department
Department of Computer Engineering

Department of Computer Engineering


Government Polytechnic,Gondia
Winter–2020

1
Certificate
This is to certify that the Micro Project titled

“Develop a program to calculate page


fault for given page reference string by
using different page replacement
Carried out under guidance of Mr. J M Meshram sir, Head Of
Department,
Computer department and submitted to the department of computer
engineering

Submitted By:-

Name of Student Enrollment No.

As the partial fulfilment of Fourth semester Subject course of “ GUI


application development using tfB.NET” code:22034 during Summer-
2020.

MR. J M MESHARAM
HEAD OF DEPARTMENT

DEPARTMENT OF COMPUTER
ENGINEERING

Department of Computer Engineering


Government Polytechnic, Gondia
Winter-2020
2
CONTENTS

Sr Title Page no.


No.

1 Rationale 4
2 Aim/Benefit of the micro-project 5
3 Course Outcomes Addressed 5
4 Literature Review 6-25
5 Actual Methodology Followed 26-25
6 Actual Resources Used 26-31
7 Outputs of the Micro-Project 32
8 Skill Developed / learning out of this Micro-Project 33
9 Applications of this Micro-Project 33

3
Micro-Project Report

Title of Micro-Project: Prepare a Report Linux all utilities command


execution in linux OS

1.0 Rationale
Page replacement algorithms are an important part of virtual memory management and it helps
the OS to decide which memory page can be moved out, making space for the currently needed
page. However, the ultimate objective of all page replacement algorithms is to reduce the number
of page faults.

2.0 Aims/Benefits Of The Micro-Project


 To Prepare Prepare a program of page replacement algorithm(fifo,lru)

 From this micro-project we can understand the working program of page replacement
algorithm.

3.0 Course Outcomes Addressed


a) Install Operating System and configure it.
b) Use Operating System tools to perform various functions.
c) Execute various commands for performing process management operations.
d) Apply scheduling algorithms to calculate turnaround time and average waiting time.
e) Calculate efficiency of Different memory management techniques.
f) Apply file management techniques.

4
4.0 Literature Review
The page replacement algorithm decides which memory page is to be replaced. The process of
replacement is sometimes called swap out or write to disk. Page replacement is done when the
requested page is not found in the main memory (page fault).

There are two main aspects of virtual memory, Frame allocation and Page Replacement. It is very important
to have the optimal frame allocation and page replacement algorithm. Frame allocation is all about how
many frames are to be allocated to the process while the page replacement is all about determining the page
number which needs to be replaced in order to make space for the requested page.

What If the algorithm is not optimal?


1. if the number of frames which are allocated to a process is not sufficient or accurate then there can be a
problem of thrashing. Due to the lack of frames, most of the pages will be residing in the main memory and
therefore more page faults will occur.

However, if OS allocates more frames to the process then there can be internal fragmentation.

2. If the page replacement algorithm is not optimal then there will also be the problem of thrashing. If the
number of pages that are replaced by the requested pages will be referred in the near future then there will
be more number of swap-in and swap-out and therefore the OS has to perform more replacements then
usual which causes performance deficiency.

Therefore, the task of an optimal page replacement algorithm is to choose the page which can limit the
thrashing.

Types of Page Replacement Algorithms


There are various page replacement algorithms. Each algorithm has a different method by which the pages
can be replaced.

Optimal Page Replacement algorithm → this algorithms replaces the page which will not be referred for so long
in future. Although it can not be practically implementable but it can be used as a benchmark. Other algorithms are
compared to this in terms of optimality.
5
Least recent used (LRU) page replacement algorithm → this algorithm replaces the page which has not been
referred for a long time. This algorithm is just opposite to the optimal page replacement algorithm. In this, we look at
the past instead of staring at future.

FIFO → in this algorithm, a queue is maintained. The page which is assigned the frame first will be replaced first. In
other words, the page which resides at the rare end of the queue will be replaced on the every page fault.

6
Program FIFO:

#include <stdio.h>
int main()
{
int referenceString[10], pageFaults = 0, m, n, s, pages, frames;
printf("\nEnter the number of Pages:\t");
scanf("%d", &pages);
printf("\nEnter reference string values:\n");
int(m = 0; m < pages; m++)
{
printf("Value No. [%d]:\t", m + 1);
scanf("%d", &referenceString[m]);
}
printf("\n What are the total number of frames:\t");
{
scanf("%d", &frames);
}
inttemp[frames];
for(m = 0; m < frames; m++)
{
temp[m] = -1;
}
for(m = 0; m < pages; m++)
{
s = 0;
for(n = 0; n < frames; n++)
{
if(referenceString[m] == temp[n])
{
s++;
pageFaults--;
}
}
pageFaults++;
if((pageFaults <= frames) && (s == 0))
{
temp[m] = referenceString[m];
}
else if(s == 0)
{
temp[(pageFaults - 1) % frames] = referenceString[m];
}
printf("\n");
for(n = 0; n < frames; n++)
{
printf("%d\t", temp[n]);
}
}
printf("\nTotal Page Faults:\t%d\n", pageFaults);
return 0;
}

7
Program LRU:

#include<stdio.h>
 
int findLRU(int time[], int n){
    int i, minimum = time[0], pos = 0;
 
    for(i = 1; i < n; ++i){
        if(time[i] < minimum){
            minimum = time[i];
            pos = i;
        }
    }
   
    return pos;
}
 
int main()
{
    int no_of_frames, no_of_pages, frames[10], pages[30], counter = 0, time[10], flag1, flag2,
i, j, pos, faults = 0;
    printf("Enter number of frames: ");
    scanf("%d", &no_of_frames);
   
    printf("Enter number of pages: ");
    scanf("%d", &no_of_pages);
   
    printf("Enter reference string: ");
   
    for(i = 0; i < no_of_pages; ++i){
        scanf("%d", &pages[i]);
    }
   
    for(i = 0; i < no_of_frames; ++i){
        frames[i] = -1;
    }
   
    for(i = 0; i < no_of_pages; ++i){
        flag1 = flag2 = 0;
       
        for(j = 0; j < no_of_frames; ++j){
            if(frames[j] == pages[i]){
                counter++;
                time[j] = counter;
                   flag1 = flag2 = 1;
                   break;
               }
        }

8
       
        if(flag1 == 0){
            for(j = 0; j < no_of_frames; ++j){
                if(frames[j] == -1){
                    counter++;
                    faults++;
                    frames[j] = pages[i];
                    time[j] = counter;
                    flag2 = 1;
                    break;
                }
            }    
        }
       
        if(flag2 == 0){
            pos = findLRU(time, no_of_frames);
            counter++;
            faults++;
            frames[pos] = pages[i];
            time[pos] = counter;
        }
       
        printf("\n");
       
        for(j = 0; j < no_of_frames; ++j){
            printf("%d\t", frames[j]);
        }
    }
   
    printf("\n\nTotal Page Faults = %d", faults);
   
    return 0;
}

9
 COMPUTER SYSTEM :
We have used DELL INSPIRON , 8th generation WITH INBUILT WINDOWS 10
Operating system of 3.20 GHz INTEL Pentium Core processor with i7technology
computer ( PC ).
Dell Inspiron desktops and all-in-one PCs are designed with innovative
technology and latest features .

 OFFICE SOFTWARE PACKAGES :


We have used MS word 2013 for creating our report to show about how we
created this website . For performing of this project we have used MICROSOFT
WORD OFFICE OF 2013 version. Microsoft Office 2013 is a version of
Microsoft Office, a productivity suite for Microsoft Windows. It is the successor
to Microsoft Office 2010 and the predecessor to Microsoft Office 2016.

 Reference Websites:

https://www.tecmint.com/top-most-popular-linux-distributions/

https://fossbytes.com/best-linux-desktop-environments/

https://en.wikipedia.org/wiki/Linux

https://whatis.techtarget.com/reference/Linux-distributions-with-GUI-install

10
5.0 Actual Methodology Followed
1. First we have collected required Information From Internet and From Websites.
2. After collecting the requirements we have Distributed the work tasks to our Team
Members.
1. After analyzing the page replacement algorithm we have Started Preparing the report
of page replacement algorithm and making program.

2. After we prepared page replacement algorithm program using c


3. After completing Application project works we have Prepared Micro-Project Report
and submitted it to our guide.

11
6.0 Actual Resources Used
S. Name of Specifications Qty. Remarks
No. Resource/material
1 Computer system Desktop or Laptop with approx. 1 Collecting
2GB RAM, 500GB HDD or Informations from
SSD with at least Intel core-i3 internet.
processor.
2 Operating system Linux OS (Ubuntu 20.0.14) 1 For Preparing
software tools Report after
analyzing OS
3 Office Software Microsoft Word 2013 or others - Preparing
Packages Demonstration
Report.

12
7.0 Outputs of the Micro-Project

FIFO

LRU

13
8.0 Skill Developed / learning out of this Micro-Project
 Skills Developed From this micro-project is that we have the working of
page replacement algorithm.

9.0 Applications of this Micro-Project


 It is open for full analysis.
 In this, we replace the page which is least recently used, thus free from
Belady’s Anomaly.
 Easy to choose page which has faulted and hasn’t been used for a long time.

**************

14

You might also like