Exploring LFU Page Replacement Algorithm in C TheLazyBusyCoder's Blog Welcome to my coding adventures! In this post, we'll explore a C program. Optimal Page Replacement(OPT) in C The page which has less frequency gets replaced #include <stdio.h> #include<stdbool.h> typedef struct Frame { int p , f , t; } Frame; void display(Frame frame[] , int framesize , bool isHit) { int i; for(i = 0; i < framesize; i++) { printf("%2d | " , frame[i].p); } if(isHit == true) printf(" HIT\n"); else printf(" *\n"); } bool find(Frame frame[] , int framesize, int cur) { int i = 0; for(i = 0; i < framesize; i++) { if(frame[i].p == cur) return true; } return false; } int replace(Frame frame[] , int framesize) { int i; for(i = 0; i < framesize; i++) if(frame[i].p == -1) return...
Comments
Post a Comment