#include<stdio.h>
#include<stdlib.h>
#include <string.h>
#dene MAX 5000 //椤垫涓 殑鏁扮粍澶 蟀
int oset = 0; //鍋忕匍??
int nd(int a, int b[], int size);
void FIFO(int input, int frame[], int frameSize); //FIFO 椤甸潰缃 崲
void LRU(int frame[], int frameSize, int from, int end); //LRU 椤甸潰缃 崲
void CLOCK(int input, int frame[], int frameSize, int clock[]); //CLOCK 椤甸潰缃
崲
int main()
{
int size[] = { 100,500,1000,2000,5000 };//椤垫澶蟀
int cpu[MAX]; //椤垫涓 殑鏁扮粍
int miss = 0; //缂洪〉鏁? FILE* fp[6];
int c; //璇诲彇鐨勯〉鍙?int count; //鎬婚〉鏁? int i, j;
//FIFO 椤甸潰缃 崲
printf("-------------FIFO------------");
for (j = 0;j<5;j++)
{
//鎵撳紑瀛樺偍椤垫鍙风殑鏁版嵁鏂囦欢锛屽彧璇? fp[0] =
fopen("workload1", "r");
fp[1] = fopen("workload2", "r");
fp[2] = fopen("workload3", "r");
fp[3] = fopen("workload4", "r");
fp[4] = fopen("workload5", "r");
fp[5] = fopen("workload6", "r");
printf("for the frame size is %d", size[j]);
for (i = 0;i<6;i++)
{
count = 0;
miss = 0;
oset = 0;
//渚濇 璇诲彇椤垫鍙风洿鑷虫枃浠跺熬
while (fscanf(fp[i], "%d*[^0-9]", &c) != EOF)
{
if (nd(c, cpu, size[j]) == -1) //缂洪〉
{
FIFO(c, cpu, size[j]);
miss++; //缂洪〉鏁板姞涓€
}
count++; //鎬婚〉鏁板姞涓€
}