Posts

Showing posts from August, 2024

IMPLEMENTATION OF LRU PAGE REPLACEMENT ALGORITHM

  IMPLEMENTATION OF LRU PAGE REPLACEMENT ALGORITHM AIM: To write a c program to implement LRU page replacement algorithm ALGORITHM : 1. Start the process 2. Declare the size 3. Get the number of pages to be inserted 4. Get the value 5. Declare counter and stack 6. Select the least recently used page by counter value 7. Stack them according the selection. 8.  Display the values 9. Stop the process PROGRAM: #include<stdio.h> main() { int q[20],p[50],c=0,c1,d,f,i,j,k=0,n,r,t,b[20],c2[20]; printf("Enter no of pages:"); scanf("%d",&n); printf("Enter the reference string:"); for(i=0;i<n;i++)             scanf("%d",&p[i]); printf("Enter no of frames:"); scanf("%d",&f); q[k]=p[k]; printf("\n\t%d\n",q[k]); c++; k++; for(i=1;i<n;i++)             {                ...

IMPLEMENTATION OF FIFO PAGE REPLACEMENT ALGORITHM

IMPLEMENTATION OF FIFO PAGE REPLACEMENT ALGORITHM  AIM To write a c program to implement FIFO page replacement algorithm ALGORITHM 1. Start the process 2. Declare the size with respect to page length 3. Check the need of replacement from the page to memory 4. Check the need of replacement from old page to new page in memory 5. Forma queue to hold all pages 6. Insert the page require memory into the queue 7. Check for bad replacement and page fault 8. Get the number of processes to be inserted 9. Display the values 10. Stop the process PROGRAM: #include<stdio.h> int main() { int i,j,n,a[50],frame[10],no,k,avail,count=0;             printf("\n ENTER THE NUMBER OF PAGES:\n"); scanf("%d",&n);             printf("\n ENTER THE PAGE NUMBER :\n");             for(i=1;i<=n;i++)    ...