資源簡介
.C.rar

代碼片段和文件信息
#include?
#include?
#define?mSIZE?3
#define?pSIZE?20
static?int?memery[mSIZE]={000};
static?int?process[pSIZE]={70120304230321201701};
void?FIFO();
void?LRU();
void?OPT();
int?main()
{
????int?codepassword;
????get();
?????????do
?????????{
?????????printf(“enter?password:“);
?????????scanf(“%d“&password);
?????????}while(password!=722);
??????do{
?????????printf(“---------------------------------------------------\n“);
?????????printf(“|???????????????????????*???????*??????*********??|\n“);
?????????printf(“|?1.FIFO????????????????*???????*??????*???*???*??|\n“);
?????????printf(“|??????????????????*******************??*******???|\n“);
?????????printf(“|?2.LRU???????????????*?*?*???*?*?*??????*????????|\n“);
?????????printf(“|????????????????????*??*??*?*??*??*????*??*??????|\n“);
?????????printf(“|?3.OPT?????????????*???*???*???*???*???*******???|\n“);
?????????printf(“|??????????????????*????*??*?*??*????*?????*??????|\n“);
?????????printf(“|?4.EXIT??????????*?????*?*???*?*?????**********??|\n“);
?????????printf(“-------------------------------------------*-------\n“);
?????????printf(“enter?your?choice:“);
?????????scanf(“%d“&code);
?????????switch(code)
????????????{
????????????case?1:{
?????????????????????FIFO();
???????????????????}break;
????????????case?2:{
?????????????????????LRU();
???????????????????}break;
????????????case?3:{
?????????????????????OPT();
???????????????????}break;
????????????case?4:{}break;
????????????}
?????????}while?(code!=4);
????system(“PAUSE“);
????return?0;
}
get()
????{
????int?in;
????for(i=0;i<20;i++)
????????{
????????printf(“%d?“process[i]);
????????}
????printf(“\n“);
????}
void?FIFO()
{
?????int?memery[mSIZE]={000};
?????int?time[mSIZE]={000};
?????int?ijk;
?????int?max=0;
?????int?count=0;
?????get();
????for(i=0;i ????????{
????????memery[i]=process[i];
????????time[i]=i;
????????????for(j=0;j ???????????????{
????????????????printf(“%d?“memery[j]);
????????????????}
????????printf(“\n“);
????????}??????/*前mSIZE個數(shù)直接放入*/
????for(i=mSIZE;i ????{
????????for(j=0k=0;j ????????????{
?????????????if(memery[j]!=process[i])
??????????????????k++;
????????????}/*判斷新頁面號是否在物理塊中*/
????????if(k==mSIZE)/*如果都不在物理塊中*/
????????????{
????????????count++;
?????????????if(time[0]????????????????max=0;
???????????????else?max=1;
?????????????if(time[2]????????????????max=2;
????????????memery[max]=process[i];
????????????time[max]=i;
????????????for(j=0;j ????????????????{
?????????????????printf(“%d?“memery[j]);
????????????????}
????????????printf(“\n“);
????????????}
????????else
????????????{
????????????for(j=0;j ????????????????{
?????????????????printf(“%d?“memery[j]);
????????????????}
????????????printf(“\n“);
????????????}
????}
?????printf(“time:%d\n“co
?屬性????????????大小?????日期????時間???名稱
-----------?---------??----------?-----??----
?????文件???????6387??2009-01-04?08:58??頁面置換算法.C.c
?????文件?????131072??2009-01-04?10:22??頁面置換實驗報告.doc
-----------?---------??----------?-----??----
???????????????137459????????????????????2
- 上一篇:music.zip
- 下一篇:SPH算法k文件.rar
評論
共有 條評論