資源簡介
操作系統 SPOOLing輸出模擬 實驗報告有實驗代碼 、可執行程序、實驗分析 完整的實驗報告。

代碼片段和文件信息
#include?
#include?
#include?
#include?
#include?
#include?
struct?PCB?????????
{???????????????????
???long?ID;???????
???int?status;??????
???long?po;????????
???long?head;???????
???long?count;??????
???long?wait[1000];?
}PCB[4];
struct?ReqBlock????
{??long?ID;???????
???long?len;??????
???long?head;?????
}ReqBlock[128];
struct?well???????
{???????????????????
???long?num[1000];??
???long?open;????
???long?closed;?
}well[3];
long?K[3];?
long?n;????
long?r;????
long?k;????
long?a;???
long?b;????
long?i;????
void?input()
{??printf(“Input?the?size?of?user1‘s?output?file:“);
???scanf(“%ld“&K[1]);
???printf(“Input?the?size?of?user2‘s?output?file:“);
???scanf(“%ld“&K[2]);
}
void?init()
{
???memset(PCB0sizeof(PCB));
???PCB[1].ID=1;
???PCB[2].ID=2;
???PCB[3].ID=3;
???PCB[3].status=2;
???memset(well0sizeof(well));
???n=0;?????????
}
void?UserServer(long?kx)
{???a=rand()%10;
???++PCB[kx].po;
???PCB[kx].wait[PCB[kx].po]=a;
???if?(a==0)
???{???well[kx].open=well[kx].closed+1;
??????for?(i=1;i<=PCB[kx].po;i++)
?well[kx].num[++well[kx].closed]=PCB[kx].wait[i];
??????PCB[kx].po=0;
??????PCB[kx].count++;
??????if?(PCB[kx].count==K[kx])??
?PCB[kx].status=3;????????
??????if?(PCB[3].status==2)???????
?PCB[3].status=0;?????????
??????if?(well[kx].closed==1000?&&?PCB[kx].status==0)
?PCB[kx].status=1;?????????
??????n++;
??????ReqBlock[n].ID=kx;
??????ReqBlock[n].head=well[kx].open;
??????ReqBlock[n].len=well[kx].closed-well[kx].open+1;
??????printf(“Process?%ld?produces?a?block?%ld!\n“kxn);
???}
}
void?SpoolingServer()
{????PCB[3].po++;
????b=PCB[3].po;
????printf(“Output?block?%ld:?(ID=%ld)\n“bReqBlock[b].ID);
????for?(i=1;i<=ReqBlock[b].len;i++)
{?????printf(“%ld?“well[ReqBlock[b].ID].num[i+ReqBlock[b].head-1]);
}
????printf(“\n“);
????if?(PCB[3].po==n)
{????PCB[3].status=2;
??????
???????if?(PCB[1].status==3?&&?PCB[2].status==3)
???PCB[3].status=3;
}
}
void?work()
{????while?(PCB[1].status!=3?||?PCB[2].status!=3?||?PCB[3].status!=3)
???{??r=rand()%100+1;???????
??????if?(r<=45)
?k=1;
??????else?if?(r<=90)
?k=2;
??else
????k=3;
??????if?(PCB[k].status!=0)
?continue;???????????
??????switch?(k)
??????{
case?1:???UserServer(1);??break;
case?2:???UserServer(2);??break;
case?3:???SpoolingServer();??break;
??????}
???}
}
void?main()
{
??printf(“\nSPOOLing?output?simulation...\n\n“);
??srand(time(NULL));
??input();????
??init();????
??work();???
??printf(“\nsimulation?over!!\n“);
??getch();
?}
?屬性????????????大小?????日期????時間???名稱
-----------?---------??----------?-----??----
?????文件????1499136??2009-11-22?21:29??操作系統-實驗4-SPOOLing輸出模擬實驗\實驗4.doc
?????文件???????2639??2009-11-16?20:29??操作系統-實驗4-SPOOLing輸出模擬實驗\spl.c
?????文件??????50725??2009-11-16?23:21??操作系統-實驗4-SPOOLing輸出模擬實驗\SPL.EXE
?????目錄??????????0??2009-11-22?21:29??操作系統-實驗4-SPOOLing輸出模擬實驗
-----------?---------??----------?-----??----
??????????????1552500????????????????????4
- 上一篇:開源單片機GPS+谷歌定位地圖
- 下一篇:基于BBS的智能輿情分析系統.docx
評論
共有 條評論