论文百事通 设为主页 会员登录 |  免费注册
代写论文 代发表论文 定制论文 毕业设计定制 期刊目录 黄金会员  
加入收藏 设为首页 |  收藏本站
首页 | 计算机 | 建筑工程 | 医药学 | 经济类 | 文学 | 英语 | 职称评定 | 计算机毕业设计 | 课程设计 | 毕业设计作品 | 投稿中心 | 下载中心 | 作品订单
  查找论文

单道批处理系统设计一个作业调度程序(c实现)

作者:论文百事通  来源:lwbst.com    【2006-09-28】    编辑:Admin

概要设计:
作业调度算法:采用先来先服务的调度算法。

每个作业由一个控制块jcb表示:包括作业名,提交时间,所需的运行时间,作业状态等。每个作业完成后打印该作业的开始运行时刻,完成时刻,周转时间,和带权周转时间。整组作业完成后计算出该组作业的平均周转时间,带权平均周转时间。

程序界面和运行过程如下:

源程序如下:
#include "stdio.h"
#include "stdlib.h"
#define getjcb(type)(type*)malloc(sizeof(type))
#define NULL 0
struct jcb{char name[10];
int htime;
int ntime;
char state;
struct jcb *link;
} *ready=NULL,*p;
typedef struct jcb JCB;

int input()
{int num,i,t=0;
void sort();
printf("\ninput process number");
scanf("%d",&num);
for(i=1;i<=num;i++)
{printf("\nThe num %d",i);
p=(JCB*)malloc(sizeof(JCB));
printf("\nthe name of process:");
scanf("%s",p->name);
printf("\nthe time need:");
scanf("%d",&p->ntime);
p->htime=t; p->state='w'; p->link=NULL;
sort();
t++;
}
return t;
}

void sort()
{JCB *flag;
if(ready==NULL)
ready=p;
else{flag=ready;
while(flag->link!=NULL)
flag=flag->link;
flag->link=p;
}
}

void show()
{JCB *pr;
printf("\n***Now the process running is :%s ",p->name);
printf("\nname\thtime\tntime\tstate\n");
printf("%s\t",p->name);
printf("%d\t",p->htime);
printf("%d\t",p->ntime);
printf("%c\t",p->state);
printf("\n\n***Now the ready queue");

for(pr=ready;pr!=NULL;pr=pr->link)
{
printf("\nname\thtime\tntime\tstate\n");
printf("%s\t",pr->name);
printf("%d\t",pr->htime);
printf("%d\t",pr->ntime);
printf("%c\t",pr->state);
}
}

void running()
{printf("\nprocess [%s] has finished\n",p->name);
free(p);
}

main()
{
char c;
int t=0; int tb,tc,ti,wi;
int tis=0,wis=0,i=0;
t=input();
while(ready!=NULL)
{c=getchar();
++i;
p=ready;
ready=p->link;
p->link=NULL;
p->state='r';
tb=t;

show();
printf("\npress any key to continue...");
c=getchar();
running();
tc=tb+p->ntime;//完成时间
ti=tc-p->htime;//周转时间
tis+=ti;
wi=ti/p->ntime;//平均带权周转
wis+=wi;
printf("\nprocess [%d] start: %d \n", i,t);
printf("\nprocess finish:%d\n",tc);
printf("\nprocess turnover:%d\n",ti);
printf("\nprocess aveturn: %d\n",wi);
t=t+p->ntime;
printf("\npress any key to continue...");
c=getchar();
}
printf("\n***The whole process has been finished");
printf("\nthe whole turnover:%d\n",tis/i);
printf("\nthe whole aveturn:%d\n",wis/i);
printf("\npress any key to continue...");
c=getchar();
}

  本课程设计包含完整源程序、可执行程序、设计文档。

 上一篇:单道批处理系统的作业调度(续2)-操作系统课程设计
 下一篇:操作系统之存储管理课程设计
本文版权归本站所有,欢迎转载。转载该文章时,请注明“来源:论文百事通 Http://www.lwbst.com”。
 
Copyright (C) 2008 Lwbst.com, All Rights Reserved 版权所有 论文百事通