计算机操作系统实验报告表格资料

合集下载
  1. 1、下载文档前请自行甄别文档内容的完整性,平台不提供额外的编辑、内容补充、找答案等附加服务。
  2. 2、"仅部分预览"的文档,不可在线预览部分如存在完整性等问题,可反馈申请退款(可完整预览的文档不适用该条件!)。
  3. 3、如文档侵犯您的权益,请联系客服反馈,我们会尽快为您处理(人工客服工作时间:9:00-18:30)。

计算机与信息

学院 实验课程:操作系统

阜阳师范学院 Fuyang Teachers College

实验报告 ====================================================================

姓名 学号:

实验报告

实验报告

实验报告

}

exit(0);

}

main( )

{ client( );

}

2.server.c

#include

#include

#include

#define MSGKEY 75

struct msgform

{ long mtype;

char mtext[1000];

}msg;

int msgqid;

void server( )

{

msgqid=msgget(MSGKEY,0777|IPC_CREAT); do

{

msgrcv(msgqid,&msg,1030,0,0);

printf(“(server)received\n”);

}while(msg.mtype!=1);

msgctl(msgqid,IPC_RMID,0);

exit(0);

}

main( )

{

server( );

}

实验报告

#include

#include

#include

#define N 12

#define B 3

#define P 5

int isInBuf(int buf[], int x, int *p)

{ int i, j = -1;

for (i = 0; i < B; i++)

{ if(buf[i] == x)

{ j = i;

break;

}

else if (buf[i] == -1)

{ (*p)++;

buf[i] = x;

j = i;

break;

}

}

if(j==-1) (*p)++;

return j;

}

int oldopt(int i, int buf[ ], int list[ ], int f[ ]) { int k, h, j=0, max=-1;

for (k = 0; k < B; k++)

{ for (h = i; h < N; h++)

if (buf[k] == list[h])

{ f[k] = h;

break;

}

if(h==N)

f[k] = N;

}

for (k = 0; k < B; k++)

{ if (max < f[k])

{ max = f[k];

j = k;

}

}

return j;

}

int main()

{ int list[N]; #include

#include

#include

#define N 12

#define B 3

#define P 5

int isInBuf(int buf[], int x, int *p) { int i, j = -1;

for (i = 0; i < B; i++)

{ if(buf[i] == x)

{ j = i;

break;

}

else if (buf[i] == -1)

{ (*p)++;

buf[i] = x;

j = i;

break;

}

}

if(j==-1) (*p)++;

return j;

}

int oldlru(int f[ ])

{ int i, j = 0, max = -1;

for (i = 0; i < B; i++)

{ if(f[i] > max)

{ max = f[i];

j = i;

}

f[i]++;

}

return j;

}

int main()

{ int list[N];

int change[N];

int buf[B], f[B], i, j,k;

int result[B][N];

int old;

int absent;

srand((int)time(NULL));

printf("\n The Random List:\n");

for (i = 0; i < N; i++)

int change[N];

int buf[B],f[B],i,j,k;

int result[B][N];

int old;

int absent;

srand((int)time(NULL));

printf("\n The Random List:\n");

for (i = 0; i < N; i++)

{ list[i] = rand() % P+1;

printf("%3d", list[i]);

}

printf("\n----------------------------------------------\n");

printf("\nOPT:\n");

absent=0;

for(i = 0; i < B; i++)

buf[i] = f[i] = -1;

for(i = 0; i < N; i++)

{ j=isInBuf(buf, list[i],&absent);

if(j== -1) //需置换页面

{ old=oldopt(i, buf, list, f);

change[i]=buf[old];

buf[old] = list[i];

}

else change[i]=-1;

for(k=0;k

result[k][i]=buf[k];

}

printf("the result is:\n");

for(i=0;i

{ for(j=0;j

printf("%3d",result[i][j]);

printf("\n");

}

printf("\nthe page is changed:\n");

for(i=0;i

{ if(change[i]== -1)

printf(" ");

else printf("%3d",change[i]);

}

printf("\nabsent:%d\n",absent);

printf("the absent vote is:%f\n",(float)absent/N);}

{ list[i] = rand() % P+1;

printf("%3d", list[i]);

}

printf("\n-------------------------------------------\n");

printf("\nLRU:\n");

absent = 0;

for(i = 0; i < B; i++)

buf[i] = f[i] = -1;

for(i = 0; i < N; i++)

{ j = isInBuf(buf, list[i],&absent);

old = oldlru(f);

if(j== -1)

{ change[i]=buf[old];

buf[old] = list[i];

f[old] = 0;

}

else

{ f[j]=0;

change[i]=-1;

}

for(k=0;k

result[k][i]=buf[k];

}

printf("the result is:\n");

for(i=0;i

{ for(j=0;j

printf("%3d",result[i][j]);

printf("\n");

}

printf("\nthe page is changed:\n");

for(i=0;i

{ if(change[i]== -1)

printf(" ");

else

printf("%3d",change[i]);

}

printf("\nabsent:%d\n",absent);

printf("the absent vote is:%f\n",(float)absent/N); }

相关文档
最新文档