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

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

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

//时间片轮转算法 typedef struct node {

char name[20]; int round; int cputime; int arrivetime; int needtime; char state; int count; struct node *next; }PCB;

PCB *ready=NULL,*run1=NULL,*finish=NULL; int num,i;

void GetFirst(); void Output(); void InsertTime(PCB *in); void InsertFinish(PCB *in); void TimeCreate(); void RoundRun();

void GetFirst() /*取得第一个就绪队列节点*/ {

run1 = ready;

if(ready!=NULL) {

run1 ->state = 'R'; ready = ready ->next; run1 ->next = NULL; }

}

void Output() /*输出队列信息*/ {

PCB *p; p = ready;

printf(\进程名\\tcpu时间\\t需要时间\\t进程状态\\t计数器\\n\ while(p!=NULL) {

printf(\e,p->count); p = p->next; }

p = finish; while(p!=NULL) {

printf(\e,p->count); p = p->next; }

p = run1; while(p!=NULL) {

printf(\e,p->count); p = p->next; } }

void InsertTime(PCB *in) /*将进程插入到就绪队列尾部*/ {

PCB *fst;

fst = ready;

if(ready == NULL) {

in->next = ready; ready = in; } else {

while(fst->next != NULL) {

fst = fst->next; }

in ->next = fst ->next; fst ->next = in; } }

void InsertFinish(PCB *in) /*将进程插入到完成队列尾部*/ {

PCB *fst; fst = finish;

if(finish == NULL) {

in->next = finish; finish = in; } else {

while(fst->next != NULL) {

fst = fst->next; }

in ->next = fst ->next;

fst ->next = in; } }

void TimeCreate() /*时间片输入函数*/ {

PCB *tmp; int i;

printf(\输入进程名字 到达时间 进程所需时间 时间片大小:\\n\ for(i = 0;i < num; i++) {

if((tmp = (PCB *)malloc(sizeof(PCB)))==NULL) {

perror(\ exit(1); }

scanf(\%d %d %d\->round)); getchar();

tmp ->cputime = 0; tmp ->state ='W'; // tmp->prio=0; tmp ->count = 0; InsertTime(tmp); } }

void RoundRun() /*时间片轮转调度算法*/ {

int flag = 1;

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