资源简介
操作系统 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
相关资源
- 升腾Win终端系统升级方法新版.doc
- Uninstall_Cortana_WINCLIENT.CN.rar
- STM32基于rt_thread操作系统的SDHC卡文件
- 操作系统 LRU算法 实验报告 及 程序代
- [免费]车载CE6.0操作系统
- 分页系统模拟实验 操作系统 课程设
- 模拟段页式虚拟存储管理中地址转换
- 操作系统实验——虚存管理实验
- 广工操作系统实验
- 广东工业大学操作系统实验四文件系
- Bochs入门教程[操作系统第一步]
- 操作系统课程设计完整版
- 磁盘调度算法的模拟实现及对比
- 模拟一个文件管理系统
- 二级文件系统(操作系统)
- uCOS编译环境建立 BC45 TASM
- Linux 操作系统实验(全)
- 操作系统实验综合设计【附代码】
- 操作系统共享内存实验
- 操作系统循环首次适应算法
- 操作系统课程设计实现可变分区存储
- 基于GTK的Linux环境下的简易任务管理器
- 操作系统课程设计 二级文件管理系统
- 加快Windows XP操作系统开机速度
- 操作系统教程课后答案华中科技大学
- 51单片机中使用ucos ii的优缺点转
- 51单片机中使用ucos ii的优缺点
- 嵌入式实时操作系统ucos-II 第二版 源
- 计算机操作系统课后_汤小丹_第四版
- 计算机操作系统(第四版)汤小丹课
评论
共有 条评论