optimal page replacement algorithm to find page fault

Solutions on MaxInterview for optimal page replacement algorithm to find page fault by the best coders in the world

showing results for - "optimal page replacement algorithm to find page fault"
Leny
17 Jan 2017
1#include<stdio.h>
2 
3int main()
4{
5    int no_of_frames, no_of_pages, frames[10], pages[30], temp[10], flag1, flag2, flag3, i, j, k, pos, max, faults = 0;
6    printf("Enter number of frames: ");
7    scanf("%d", &no_of_frames);
8    
9    printf("Enter number of pages: ");
10    scanf("%d", &no_of_pages);
11    
12    printf("Enter page reference string: ");
13    
14    for(i = 0; i < no_of_pages; ++i){
15        scanf("%d", &pages[i]);
16    }
17    
18    for(i = 0; i < no_of_frames; ++i){
19        frames[i] = -1;
20    }
21    
22    for(i = 0; i < no_of_pages; ++i){
23        flag1 = flag2 = 0;
24        
25        for(j = 0; j < no_of_frames; ++j){
26            if(frames[j] == pages[i]){
27                   flag1 = flag2 = 1;
28                   break;
29               }
30        }
31        
32        if(flag1 == 0){
33            for(j = 0; j < no_of_frames; ++j){
34                if(frames[j] == -1){
35                    faults++;
36                    frames[j] = pages[i];
37                    flag2 = 1;
38                    break;
39                }
40            }    
41        }
42        
43        if(flag2 == 0){
44        	flag3 =0;
45        	
46            for(j = 0; j < no_of_frames; ++j){
47            	temp[j] = -1;
48            	
49            	for(k = i + 1; k < no_of_pages; ++k){
50            		if(frames[j] == pages[k]){
51            			temp[j] = k;
52            			break;
53            		}
54            	}
55            }
56            
57            for(j = 0; j < no_of_frames; ++j){
58            	if(temp[j] == -1){
59            		pos = j;
60            		flag3 = 1;
61            		break;
62            	}
63            }
64            
65            if(flag3 ==0){
66            	max = temp[0];
67            	pos = 0;
68            	
69            	for(j = 1; j < no_of_frames; ++j){
70            		if(temp[j] > max){
71            			max = temp[j];
72            			pos = j;
73            		}
74            	}            	
75            }
76			
77			frames[pos] = pages[i];
78			faults++;
79        }
80        
81        printf("\n");
82        
83        for(j = 0; j < no_of_frames; ++j){
84            printf("%d\t", frames[j]);
85        }
86    }
87    
88    printf("\n\nTotal Page Faults = %d", faults);
89    
90    return 0;
91}
92
queries leading to this page
fifo lru opr hit ratio 4 5 6 7 5 6 3 6 2 1 in cchoose the correct statement 3a 1 point fifo replaces the oldest page in main memory lfu replace the page with the smallest count lru is easy to implement all of abovelru and optimal page replacement algorithmlru example in osoptimal page replacing algolru page faultoptimal page teplacemant algofind the no of page faults for the following reference string 3a 1 2c2 2c3 2c4 2c1 2c2 2c5 2c1 2c2 2c3 2c4 2c5 using fifo page replacement algorithm with 3 page framespage fault algorithms in oscode to find the number of page fault 2c hit ratio by implementing the optimal page replacement algorithmonsider the following reference string 3a 4 2c 3 2c 1 2c 5 2c 4 if 2c there are 3 empty 28free 29 frames in the main memory and opt 28optimal 29 page replacement technique is used 2c then how many page faults will occur calculate the number of page faults in the given reference string using fifo page replacement algorithm reference string 3a 7 0 1 2 0 3 0 4 2 3 0 3 2 1 2 0 1 1 pointpage fault optimal replacementfifo lru opr 4 5 6 7 5 6 3 6 2 1optimal algorithm page replacementdifferennt page replacement algorithmswhich of the following are examples of page replacement policies 3fcompare all page replacement policies for a sample requested string with increasing number of frames and hit ratioexplain the page replacement algorithmooptimal phase replacement algorithmconsider the following reference string 7 2c 0 2c 1 2c 2 2c 0 2c 3 2c 0 2c 4 2c 2 2c 3 2c 0 2c 3 2c 2 2c 1 2c 2 2c 0 2c 1 2c 7 2c 0 2c 1 apply fifo 2c lru and optimal algorithm calculate the number of page faults that occur in each case if the number of free frames are 3 2cfifo page replacement algorithm in os 22for lru page replacement using 4 frames 22implementation and analysis of page replacement policies virtual memory codethe page replacement algorithm that yields the minimum page fault rate ispage replacement algorithms in caoa fifo replacement algorothimthe different page replacement algorithmsfifo page replacementcalculate the number of page faults using fifooptimal page replacement algorithm 1 2c2 2c3 2c4 2c1 2c2 2c3 2c2 2c4 2c6page swapping techniques find the number of page fault page with lru page if three frames areoptimal page replacement algorithm to find page faultfor 3 page frames 2c the following is the reference string 3a7 0 1 2 7 2 how many page faults does the fifo page replacement algorithm produce 3fexamples of lru page replacement algorithmchoose the correct statement 3a fifo replaces the oldest page in main memory lfu replace the page with the smallest count lru is easy to implement all of abovewhich of the following concepts is optimal page replacement algorithm based onlru algortim examplesimplementation and analysis of page replacement policies virtual memoryone page algohow to find page fault in page replacement algorithmcalculate page faults using fifofind the number of page faults 2c hit ratio by implementing the optimal page replacement algorithmin the reference string has total 20 request and by using lru algorithm total 8 page fault is generated then what will be the miss ratio for this given string 3fin the reference string has total 17 request and by using fifo algorithm total 6 page fault is generated then what will be the hit ratio for this given string 3fpage replacement techniqueswhich page replacement algorithm has maximum page fault rateconsider the page references 7 2c 0 2c 1 2c 2 2c 0 2c 3 2c 0 2c 4 2c 2 2c 3 2c 0 2c 3 2c 2 2c with 4 page frame find number of page faults using optimal page replacement algorithm and find out hit ratio least recently used algorithm frame size 4 for the proces poptimal page replacementin an operating system which of the following is not a page replacement algorithmfifo and lruconsider the page references 7 2c 0 2c 1 2c 2 2c 0 2c 3 2c 0 2c 4 2c 2 2c 3 2c 0 2c 3 2c 2 2c with 4 page frame find number of page fault using optimal page replacement algorithm and find out hit ratio paging algorithmopt algorithm page replacement 22what are the number of page faults using lru replacement policy 3f show your work 22how to do opt in os examplelfu page replacement algorithm compare the performance of the algorithms using the page hit ratio 4 3 2 0 1 2 0 4 3 5 2 0 1 2 3fifo page faultpage reference operating systemwhen does a page fault occur 3f explain various page replacement strategies 2falgorithms page fault in os exampledynamic allocation of page replacement algorithmsin the reference string has total 17 request and by using fifo algorithm total 6 page fault is generated then whata will be the hit ratio for this given string 3fcurrently employed page replacement policy is fifo and the capacity of storing 6 page frames at any instance of time the page reference string is bcabxdaazadwcbc can you tell the count of the page faults 3freplacement algorithmoptimal number of page frames for lrufifo page replacement algorithmfcfs replacement algorithmexamples of fifo page replacement algorithm usespage replacement algorithmscondider the feference string 4 2c3 2c2 2c1 2c 2c 2c 3 2c5 2c 4 2c 3 2c 2 2c2 2c5 how many page faults occur for lru page repacement algorithm with 3 frames 3fwhat is page replacement algorithmlru page replacement algorithm examplefirst in first out page replacement algorithm examplelru page replacement algorithmfifo page replacement algorithm page sizevirtual mem replacement algo gfgpage hit in page replacement algorithmpage replacement algorithmoptimal number of frames for lrureplacement algorithm in oswhat is the number of page faults for an optimal page replacement stratergywhich of the following are examples of page replacement policiesfifo and lru page replacement algorithmsthe page replacement algorithm which gives the lowest page fault rate ispage replacement in oslru optimal solved problemcalculate page faults using optimal algorithmopt page replacementimplementation of fifo page replacement algorithm and compute no of page faultsa page replacement algorithmwhat is the optimal page e2 80 93 replacement algorithm 3fexplain various page replacement algorithmspage replacement algorithms in osfor the given string 2c find out the number of page fault for fifo and lru algorithm where frame size is 4 2 2c3 2c1 2c5 2c3 2c2 2c6 2c7 2c3 2c2 2c3 2c1 2c9 2c7 2c1 2c3 2c2 2c3 2c1 2c71 092 09consider the given page references in that order 3 2c 2 2c 1 2c 0 2c 2 2c 7 2c 2 2c 4 2c 0 2c 7 2c 2 2c 7 2c 0 with 4 page frame the number of page fault using optimal page replacement and least recently used page replacement algorithms respectively is given by 3aconsider the following page reference string 3a 2 2c 3 2c 4 2c 2 2c 1 2c 5 2c 6 2c 4 2c 1 2c 2 2c 3 2c 7 2c 6 2c 3 2c 2 2c 1calculate the number of page faults would occur for fifo 2c lru and optimalpage replacement algorithm with frame size of 5how to code hit ratio of optimal page replacement paging algorithmssolve the following for fifo 2c lru and optimal the following page sequence is given 3a 2 3 4 2 1 3 7 5 4 3 1 2 3 assume page frame size as 3 calculate hit ratio and fault ratio page faults with 4 page framespage replacement policiesoptimal page replacement algorithm in c with hit ratiopage replacement algorithm according to page faultos page replacement algorithmswhat is page replacementwrite a program which finds page faults of above pages using fifofifo page replacement policy 3a 28each column is 1 5 point 3b the number of page faults is 4 5 points 29find the number of page fault 2c hit ratio by implementing the optimal page replacement algorithmoptimal page replacement algorithm in operating systemconsider the following page reference string 3a 6 5 3 4 6 5 4 3 2 6 calculate page faults using fifo page replacement algorithm with 3a a 29 page frame 3d 3fifo coaoptimal algorith for page replacementmost recently used page replacement algorithm use caseswhich of the following policy is related to page replacement 3f 2a 1 point lest recently used last in first out longest used first in first outconsider the following reference string 3a 4 2c 3 2c 1 2c 5 2c 4 if 2c there are 3 empty 28free 29 frames in the main memory and opt 28optimal 29 page replacement technique is used 2c then how many page faults will occur for the following page reference string 2c which of the given options is the correct number of page faults in the optimal page replacement algorithm with five frames 3f which of the following paging algorithms is most likely to be used in a virtual memory system 3f 1 fifo 2 second chance 3 least recently used 4 least frequently usedpage table algorithmstream processing page replacementewhat is mean of replacement algorithm acapage frame replacement algorithmcode to find the number of page faults 2c hit ratio by implementing the optimal page replacement algorithmoptimal page replacement algorithm procedure 22what is smallest number of page replacements 22optimal page replacement algorithm page faultpage replacement algorithms first in first out 22fifo 22 replacement for lru algorithmoptimal replacement typesin optimal page replacement what if page to be replaced have two enteriesin which one of following page replacement policies 2c increasing the number of page frames results in an increase in the number of page faults 2a optimal and lru optimal fifo none of these lruusing the fifo replacement policy what would the final state of the page frame be 2c as well as indicate when they were last accessed given the following sequence of page referencespage blank algorithmpage swapping techniquespage replacement algorithm gives the lowest page fault rateoptimised page replacement algorithm in operating systemoptimal page replacement algorithmpage fault formula for 3 frameswhich of the following requires future reference of the strings lfu lfu lru lru optimal optimal fifoin terms of page swapping 2c let 27s assume we use the fifo strategy is this a good strategy for frequently used pages 3f what about lfu and lru 3fos paging algorithmsoptimal page replacement algorithm examplesplage replacement algorithmhit ratio in optimal page replacement algorithmconsider a given memory reference string examples of fifo page replacement algorithmcomputer os page fault calculatorin which one of the following page replacement algorithm it is possible for the page fault rate to increasefifo page replacement algorithm with 4 framesoptimalpage replacement algorithmoptimal replacement algorithmoptimal page replacement algorithm to find page fault