#include "stdio.h"
#include <stdlib.h>
#include <conio.h>
#define getpch(type)(type*)malloc(sizeof(type))
#define NUll 0
struct pcb
{ /*定义进程控制块PCB*/
char name[10];
char state;
int itime;
int ntime;
int rtime;
struct pcb* link;
}
*ready=NULL,*p;
typedef struct pcb PCB;
sort()/*建立进程进入后备作业队列的先后次序的函数*/
{
PCB *first,*second;
int insert=0;
if((ready==NULL)||((p->itime)<(ready->itime)))/*次序最小者,插入队首*/
{
p->link=ready;
ready=p;
}
else/*进程比较先后次序,插入适当的位置中*/
{
first=ready;
second=first->link;
while(second!=NULL)
{
if((p->itime)<(second->itime))/*若插入进程比当前进程次序小,插入到当前进程前面*/
{
p->link=second;
first->link=p;
second=NULL;
insert=1;
}
else /*插入进程次序最大,则插入到队尾*/
先来先服务算法
最新推荐文章于 2022-12-30 22:12:51 发布
这个博客展示了如何使用C语言实现操作系统中的先来先服务(FCFS)调度算法。通过创建进程控制块(PCB),进行进程排序、输入、显示、检查和撤销等操作,模拟了FCFS算法的过程。
摘要由CSDN通过智能技术生成