Section 1: FIFO Page Replacement Algorithm In FIFO page replacement, the pages are simply placed in a queue when they enter the system; when a replacement occurs, the page at the beginning of the queue (the "first-in" page) is evicted. FIF0 has one great strength: it is quite simple to implement. Developing the FIFO page replacement algorithm For the FIFO page replacement algorithm, read the number of pages in the sequence, the page number sequence string, and the number of frames. Identify the page faults and calculate the total number of page faults. FIRST IN FIRST OUT (FIFO) Number of Frames: Number of Pages: 3 20 Page numbers: 7 01 11 21 3 4 2 1 2 1 7 1 Page Frame 1 Page Frame 2 Page Frame 3 7 7 2 2 2 2 4 4 4 7 7 7 3 3 2 2 2 1 1 1 1 1 1 1 3 3 3 3 2 2 2 2 Page Fault # 1 2 3 4 4 7 8. 9. 10 10 10 11 12 12 12 13 14 15 3. 2.

Computer Networking: A Top-Down Approach (7th Edition)
7th Edition
ISBN:9780133594140
Author:James Kurose, Keith Ross
Publisher:James Kurose, Keith Ross
Chapter1: Computer Networks And The Internet
Section: Chapter Questions
Problem R1RQ: What is the difference between a host and an end system? List several different types of end...
icon
Related questions
Question

Filll in the below code in C program:

#include <stdio.h>

void main()

{

int pageNumbers[25], frameContents[25];

int i = 0, j = 0, k = 0;

int numPages = 0, numFrames = 0, totalPageFaults = 0;

int frameNumber = 0;

printf("\n Page Replacement Method: FIFO");

printf("\n Enter the number of pages in the page sequence: ");

// 20

scanf("%d", &numPages);

printf("\n Enter the page numbers in sequence as a string: ");

// 7 0 1 2 0 3 0 4 2 3 0 3 2 1 2 0 1 7 0 1

for (i = 0; i < numPages; i++)

scanf("%d", &pageNumbers[i]);

printf("\n Enter the number of frames: ");

// 3

scanf("%d", &numFrames);

for (i = 0; i < numFrames; i++)

frameContents[i] = -1;

printf("\n The Page Replacement Process is \n");

printf("\tREF STRING");

for (j = 0; j < numFrames; j++)

printf("\tPAGE_FRAME_%d", j + 1);

printf("\tPAGE_FAULT_NUMBER\n");

/* Find the occurance of page faults and the total number of page faults */

printf("\n\n Total number of Page Faults using FIFO: %d \n", totalPageFaults);

}

Output:
Page Replacement Method: FIFO
Enter the number of pages in the page sequence: 20
Enter the page numbers in sequence as a string: 7 0 1 2 0 3 0 4 2 3 0 3 2 1 2 0 1 7 0 1
Enter the number of frames: 3
The Page Replacement Process is
REF STRING
PAGE_FRAME_1
PAGE_FRAME_2
PAGE_FRAME_3
PAGE_FAULT_NUMBER
7
7
-1
-1
1
7
-1
2
1
7
1
3
2
1
4
2
1
3
2
3
1
5
2
3
6
4
4
3
7
2
4
2
8
3
4
2
3
9
2
3
10
3
2
3
2
2
3
1
1
3
11
2
1
2
12
1
2
1
1
2
7
7
1
2
7
2
14
1
7
1
15
Total number of Page Faults using FIFO: 15
m + n
Transcribed Image Text:Output: Page Replacement Method: FIFO Enter the number of pages in the page sequence: 20 Enter the page numbers in sequence as a string: 7 0 1 2 0 3 0 4 2 3 0 3 2 1 2 0 1 7 0 1 Enter the number of frames: 3 The Page Replacement Process is REF STRING PAGE_FRAME_1 PAGE_FRAME_2 PAGE_FRAME_3 PAGE_FAULT_NUMBER 7 7 -1 -1 1 7 -1 2 1 7 1 3 2 1 4 2 1 3 2 3 1 5 2 3 6 4 4 3 7 2 4 2 8 3 4 2 3 9 2 3 10 3 2 3 2 2 3 1 1 3 11 2 1 2 12 1 2 1 1 2 7 7 1 2 7 2 14 1 7 1 15 Total number of Page Faults using FIFO: 15 m + n
Section 1: FIFO Page Replacement Algorithm
In FIFO page replacement, the pages are simply placed in a queue when they enter the system; when a
replacement occurs, the page at the beginning of the queue (the "first-in" page) is evicted. FIFO has one great
strength: it is quite simple to implement.
Developing the FIFO page replacement algorithm
For the FIFO page replacement algorithm, read the number of pages in the sequence, the page number
sequence string, and the number of frames. Identify the page faults and calculate the total number of page
faults.
FIRST IN FIRST OUT (FIFO)
Number of Frames:
3.
Number of Pages:
20
Page numbers:
71
1
2
3
4
2
3
3
2
1
1
7
1
Page Frame 1
7
7
2
2
4
4
4
7
7
Page Frame 2
3
2
2
1
1
1
1
1
Page Frame 3
1
1
1
1
3
3
3
3
3
2
2
2
Page Fault #
1
2 3
4
4
6.
7
8 9
10
10
10
11
12
12
12
13
14
15
2.
->
Transcribed Image Text:Section 1: FIFO Page Replacement Algorithm In FIFO page replacement, the pages are simply placed in a queue when they enter the system; when a replacement occurs, the page at the beginning of the queue (the "first-in" page) is evicted. FIFO has one great strength: it is quite simple to implement. Developing the FIFO page replacement algorithm For the FIFO page replacement algorithm, read the number of pages in the sequence, the page number sequence string, and the number of frames. Identify the page faults and calculate the total number of page faults. FIRST IN FIRST OUT (FIFO) Number of Frames: 3. Number of Pages: 20 Page numbers: 71 1 2 3 4 2 3 3 2 1 1 7 1 Page Frame 1 7 7 2 2 4 4 4 7 7 Page Frame 2 3 2 2 1 1 1 1 1 Page Frame 3 1 1 1 1 3 3 3 3 3 2 2 2 Page Fault # 1 2 3 4 4 6. 7 8 9 10 10 10 11 12 12 12 13 14 15 2. ->
Expert Solution
steps

Step by step

Solved in 4 steps with 3 images

Blurred answer
Recommended textbooks for you
Computer Networking: A Top-Down Approach (7th Edi…
Computer Networking: A Top-Down Approach (7th Edi…
Computer Engineering
ISBN:
9780133594140
Author:
James Kurose, Keith Ross
Publisher:
PEARSON
Computer Organization and Design MIPS Edition, Fi…
Computer Organization and Design MIPS Edition, Fi…
Computer Engineering
ISBN:
9780124077263
Author:
David A. Patterson, John L. Hennessy
Publisher:
Elsevier Science
Network+ Guide to Networks (MindTap Course List)
Network+ Guide to Networks (MindTap Course List)
Computer Engineering
ISBN:
9781337569330
Author:
Jill West, Tamara Dean, Jean Andrews
Publisher:
Cengage Learning
Concepts of Database Management
Concepts of Database Management
Computer Engineering
ISBN:
9781337093422
Author:
Joy L. Starks, Philip J. Pratt, Mary Z. Last
Publisher:
Cengage Learning
Prelude to Programming
Prelude to Programming
Computer Engineering
ISBN:
9780133750423
Author:
VENIT, Stewart
Publisher:
Pearson Education
Sc Business Data Communications and Networking, T…
Sc Business Data Communications and Networking, T…
Computer Engineering
ISBN:
9781119368830
Author:
FITZGERALD
Publisher:
WILEY