当前位置: 技术问答>linux和unix
LRU页面调度算法调试问题——请高手帮忙!!!!
来源: 互联网 发布时间:2015-07-03
本文导语: #define TURE 1 #define FALSE 0 #define INVALID -1 #define NULL 0 #define total_instruction 320 #define total_vp 32 #define clear_period 50 typedef struct{ int pn,pfn,counter,time; } pl_type; pl_type pl[total_vp]; struct pfc_struct{ int pn,pfn; struct pfc_struc...
#define TURE 1
#define FALSE 0
#define INVALID -1
#define NULL 0
#define total_instruction 320
#define total_vp 32
#define clear_period 50
typedef struct{
int pn,pfn,counter,time;
}
pl_type;
pl_type pl[total_vp];
struct pfc_struct{
int pn,pfn;
struct pfc_struct *next;
};
typedef struct pfc_struct pfc_type;
pfc_type pfc[total_vp], *freepf_head, *busypf_head, *busypf_tail;
int diseffect, a[total_instruction];
int page[total_instruction], offset[total_instruction];
void initialize();
void fifo();
void lru();
#include
#include
main()
{
int s,i,j;
srand(getpid()*10);
s=(float)319*rand()/32767+1;
for(i=0;inext;
freepf_head->next=NULL;
freepf_head->pn=page[i];
pl[page[i]].pfn=freepf_head->pfn;
if(busypf_tail==NULL)
busypf_head=busypf_tail=freepf_head;
else
{
busypf_tail->next=freepf_head;
busypf_tail=freepf_head;
}
freepf_head=p;
}
}
printf("fifo:%6.4",1-(float)diseffect/320);
}
void lru(total_pf)
int total_pf;
{
int min,minj,i,j,present_time;
initialize(total_pf);present_time=0;
for(i=0;inext=NULL;
}
pl[page[i]].pfn=freepf_head->pfn;
pl[page[i]].time=present_time;
freepf_head=freepf_head->next;
}
else
pl[page[i]].time=present_time;
present_time++;
}
printf("lru:%6.4f",1-(float)diseffect/320);
}
void initialize(total_pf)
int total_pf;
{
int i;
diseffect=0;
for(i=0;i
#define FALSE 0
#define INVALID -1
#define NULL 0
#define total_instruction 320
#define total_vp 32
#define clear_period 50
typedef struct{
int pn,pfn,counter,time;
}
pl_type;
pl_type pl[total_vp];
struct pfc_struct{
int pn,pfn;
struct pfc_struct *next;
};
typedef struct pfc_struct pfc_type;
pfc_type pfc[total_vp], *freepf_head, *busypf_head, *busypf_tail;
int diseffect, a[total_instruction];
int page[total_instruction], offset[total_instruction];
void initialize();
void fifo();
void lru();
#include
#include
main()
{
int s,i,j;
srand(getpid()*10);
s=(float)319*rand()/32767+1;
for(i=0;inext;
freepf_head->next=NULL;
freepf_head->pn=page[i];
pl[page[i]].pfn=freepf_head->pfn;
if(busypf_tail==NULL)
busypf_head=busypf_tail=freepf_head;
else
{
busypf_tail->next=freepf_head;
busypf_tail=freepf_head;
}
freepf_head=p;
}
}
printf("fifo:%6.4",1-(float)diseffect/320);
}
void lru(total_pf)
int total_pf;
{
int min,minj,i,j,present_time;
initialize(total_pf);present_time=0;
for(i=0;inext=NULL;
}
pl[page[i]].pfn=freepf_head->pfn;
pl[page[i]].time=present_time;
freepf_head=freepf_head->next;
}
else
pl[page[i]].time=present_time;
present_time++;
}
printf("lru:%6.4f",1-(float)diseffect/320);
}
void initialize(total_pf)
int total_pf;
{
int i;
diseffect=0;
for(i=0;i