C Program FIFO Page Replacement Policy : Explanation

Step 1 : Accept Given Data .

1. Frame Number  : fno
2. Number of Pages  : count
3. Actual Pages : arr[100]
```void accept(){int i;printf("nEnter the number of Frames : ");scanf("%d",&fno);printf("nEnter the number of Pages : ");scanf("%d",&count);printf("nEnter the Page No : ");for(i=0;i< count;i++)    scanf("%d",&arr[i]);}

Step 2 :

Now we have Pages and Frame Size.
Total Number of Pages is Given by Variable : “Count“.

Logic :

Now We are Creating Circular Linked List Whose Size is equal to “Frame Size“
Initialize Each Node’s Data = -99.
-99 Tells us That Place is Empty
Call Create Function.

Size of Linked List = Frame Size

Step 3 :

After Creating Initial Setup Call Function : fifo().
While Inserting Element in Frame [i.e in Linked List ] We have to Check Whether –

Page number is Already Present or Not.
There is Empty Location or not.

temp = start;  //Temporary Purposelast = start;  //Replacement Purposecurr = start;  //Current Purpose ->-99
We have To insert Total Number of Pages = “Value Specified in Count” so we requires 1 for loop.
for(i=0;i< count;i++)

Check Whether First Page is already Present or not.

res = search(arr[i]);

If Page is Present then Don’t Take any Action , and Read Next Page.
But If Page is Present then we have to insert Page in Linked List

Step 4 :
if(res == 0)     {     fault++;     if(curr->data == -99)        {        curr->data = arr[i];        curr = curr->next;        }     else        {        last ->data = arr[i];        last = last->next;        }     }//end outer if

If Linked List have Blank Space then First “If Part” gets Executed.
If Linked List doesn’t have Blank Space then Overwrite on the Oldest Node. [ “last”  is used for Keeping Track of Oldest Node , After Overwriting Move “last” one position ahead. ]

var disqus_config = function () {
this.page.url = PAGE_URL;  // Replace PAGE_URL with your page's canonical URL variable
this.page.identifier = PAGE_IDENTIFIER; // Replace PAGE_IDENTIFIER with your page's unique identifier variable
};
*/
(function() { // DON'T EDIT BELOW THIS LINE
var d = document, s = d.createElement('script');
s.src = 'https://programmingtutorials.disqus.com/embed.js';
s.setAttribute('data-timestamp', +new Date());
})();

Previous Page

Next Page