第一范文网 - 专业文章范例文档资料分享平台

计算机操作系统课程设计源代码《通用处理机调度演示程序源代码》

来源:用户分享 时间:2025/7/21 12:44:43 本文由loading 分享 下载这篇文档手机版
说明:文章内容仅供预览,部分内容可能不全,需要完整文档或者需要复制内容,请下载word后使用。下载word有问题请添加微信号:xxxxxxx或QQ:xxxxxx 处理(尽可能给您提供完整文档),感谢您的支持与谅解。

GetFirst();

while(run1 != NULL) {

Output(); while(flag) {

run1->cputime++ ; run1->needtime--;

run1->count++;

if(run1->needtime == 0) {

run1 ->state = 'F'; InsertFinish(run1); flag = 0; }

else if(run1->count == run1->round) {

run1->state = 'W'; run1->count=0; InsertTime(run1); flag = 0; } } flag = 1; GetFirst(); } }

//先来先服务算法

typedef struct PCB //定义进程控制块 {

char ID[3]; //进程号

char name[10]; //进程名 char state; //运行状态 int arrivetime; //到达时间 int starttime; //进程开始时间 int finishtime; //进程结束时间 int servicetime; //服务时间 float turnaroundtime;//周转时间

float weightedturnaroundtime;//带权周转时间 struct PCB *next; //指向下个进程 }pcb;

int time; //计时器 int n; //进程个数

pcb *head1=NULL,*p,*q; //进程链表指针

void run_fcfs(pcb *p1) //运行未完成的进程 {

time = p1->arrivetime > time? p1->arrivetime:time; p1->starttime=time;

printf(\现在时间是%d,开始运行作业%s\\n\ time+=p1->servicetime; p1->state='T'; p1->finishtime=time;

p1->turnaroundtime=p1->finishtime-p1->arrivetime;

p1->weightedturnaroundtime=p1->turnaroundtime/p1->servicetime; printf(\ 到达时间 开始时间 服务时间 完成时间 周转时间 带权周转时间 \\n\ printf(\

p1->ID,p1->arrivetime,p1->starttime,p1->servicetime,p1->finishtime,

p1->turnaroundtime,p1->weightedturnaroundtime); }

void fcfs() //找到当前未完成的进程 {

int i,j; p=head1; for(i=0;i

if(p->state=='F') {

q=p; //标记当前未完成的进程 run_fcfs(q); }

p=p->next; } }

void getInfo() //获得进程信息并创建进程 {

int num;

printf(\作业个数:\ scanf(\

for(num=0;num

p=(pcb *)malloc(sizeof(pcb));

printf(\依次输入:\\nID 进程名 到达时间 服务时间\\n\

scanf(\ if(head1==NULL) {head1=p;q=p;time=p->arrivetime;} if(p->arrivetime < time) time=p->arrivetime; q->next=p; p->starttime=0; p->finishtime=0; p->turnaroundtime=0;

p->weightedturnaroundtime=0; p->next=NULL; p->state='F';

q=p; } }

//静态优先权优先算法

int SequenceNumber=1; //进程编号 int ProcessAmount; int StartCount=0;

struct PCB1{ };

struct PCB1 *head,*thisP,*newP;

struct PCB1 *readyHead;

//函数声明 int getch();

int timeOfData(FILE *); void ListAllPCB(); void Menu();

void printPCB(struct PCB1 *,int,int,int,double); void printPCBP(struct PCB1 *); void printField(); void printFieldP();

void release(struct PCB1 *);

//动态存储就绪队列 //动态接收进程及详细

int No;

//进程控制块

//进程数量 //调入内存进程计数

//进程号 //进程名

char name[16];

int enterMemoryTime;//进入内存时间 int serviceTime; //服务时间 int priority;

//优先级

struct PCB1 *next;

计算机操作系统课程设计源代码《通用处理机调度演示程序源代码》.doc 将本文的Word文档下载到电脑,方便复制、编辑、收藏和打印
本文链接:https://www.diyifanwen.net/c2c9lt7wr8z9pugm7qnnb9acj39qq6000eh9_3.html(转载请注明文章来源)
热门推荐
Copyright © 2012-2023 第一范文网 版权所有 免责声明 | 联系我们
声明 :本网站尊重并保护知识产权,根据《信息网络传播权保护条例》,如果我们转载的作品侵犯了您的权利,请在一个月内通知我们,我们会及时删除。
客服QQ:xxxxxx 邮箱:xxxxxx@qq.com
渝ICP备2023013149号
Top