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

void releaseR(struct PCB1 *); void setNewPCB(char *,int,int,int); struct PCB1 * runTheProcess();

void newPCB(){ }

thisP->next=NULL;

thisP->No=SequenceNumber; SequenceNumber++;

printf(\进程号 %d\\n\printf(\输入进程名:\scanf(\printf(\输入优先级:\scanf(\printf(\输入进入内存时间:\

scanf(\printf(\输入服务时间:\

scanf(\thisP=newP; if(head==NULL){

head=newP;

//判断头节点是否为空

//为空,头节点指向新开辟的内存

//建立PCB

newP=(struct PCB1 *)malloc(sizeof(struct PCB1));

}else{ }

thisP=head;

while(thisP->next!=NULL){ }

thisP->next=newP;

//遍历单链表,找到最后一个元素

thisP=thisP->next;

void buildProcess(){ }

int i=0;

//创建进程

printf(\输入进程数量:\scanf(\while(i

newPCB(); i++;

void readyList(struct PCB1 *pcb){ }

struct PCB1 * callMemory(){

int at;

//到达时间

if(readyHead==NULL){

readyHead=newP;

//单链表的形式创建就绪队列

newP=(struct PCB1 *)malloc(sizeof(struct PCB1));

}else{ }

thisP=newP;

strcpy(thisP->name,pcb->name); thisP->No=pcb->No;

thisP->priority=pcb->priority;

thisP->enterMemoryTime=pcb->enterMemoryTime; thisP->serviceTime=pcb->serviceTime; thisP->next=NULL;

thisP=readyHead;

while(thisP->next!=NULL){ }

thisP->next=newP;

thisP=thisP->next;

//调入内存,返回调入内存的链表节点

struct PCB1 *markP;

if(head==NULL){

printf(\程序没有找到。\\n\

}else{

markP=thisP=head;

//标记指向头节点

//到达时间为头节点到达时间

at=thisP->enterMemoryTime; while(thisP->next!=NULL){

//当下一节点不为空

//判断当前时间是否大于下一

if(at>thisP->next->enterMemoryTime){

节点时间 }

void run(){

//静态优先级算法执行。

}

return markP;

}

}

thisP=thisP->next; //向后遍历

markP=thisP->next;

//是,标记此节点

at=markP->enterMemoryTime; //到达时间更改为标记时间

struct PCB1 *temp; //临时节点用来存储调入内存节点 struct PCB1 *runPro; int i;

//用来接收执行的节点

//循环初始条件

//到达时间,开始执行时间,运行时间。 //周转时间

int at,srt,runtime=0; int turnOverTime; double ptot;

//带权周转时间

if(head==NULL){

printf(\没有发现进程。\\n\

}else{

for(i=0;i

while(head!=NULL){

temp=callMemory();

if(i==0){//初始情况下球开始执行时间,完成时间,周转时间,带权周转

//循环进程的数量次

时间

srt=at=temp->enterMemoryTime; runtime=at+temp->serviceTime;

}

}

turnOverTime=runtime-at;

ptot=turnOverTime*1.0/temp->serviceTime;

readyList(temp); //初始纳入就绪列表以及后续 release(temp);

//释放进程

while(head!=NULL&&(temp=callMemory())->enterMemoryTime<=runtime){ }

}

}

runPro=runTheProcess(); if(i>0){ }

printf(\当前执行的进程:\\n\printField();

printPCB(runPro,srt,runtime,turnOverTime,ptot); releaseR(runPro);

printf(\就绪进程列表:\\n\ListAllPCB(readyHead); printf(\

//初始之后,计算各时间及周转

}

readyList(temp); //循环判断是否纳入就绪列表 release(temp);

srt=runtime;

runtime+=runPro->serviceTime;

turnOverTime=runtime-runPro->enterMemoryTime; ptot=turnOverTime*1.0/runPro->serviceTime;

struct PCB1 * runTheProcess(){ //执行的进程,返回要执行进程的节点

int time,pri;

struct PCB1 *markThis; //标记要返回的节点 if(readyHead==NULL){

printf(\没有可运行的进程。\\n\