#include<stdio.h>
#include<stdlib.h>
#define READY 1
#define BLOCK 2
struct PCB
{
int ID;//进程id
int PRIORITY;//进程优先级,越大越优先
int CPUTIME;//已经运行的时间片
int ALLTIME;//还要运行的时间片
int STARTBLOCK;//进程开始变成BLCOK的时间片
int BLOCKTIME;//经过BLCOKTIME之后进程由BLOCK转变成READY
int STATE;//进程的状态READY--1,BLOCK--2
PCB *next;//指向下一个进程
PCB(int a1,int a2,int a3,int a4,int a5,int a6,int a7)
{
ID=a1;PRIORITY=a2;CPUTIME=a3;ALLTIME=a4;
STARTBLOCK=a5;BLOCKTIME=a6;
STATE=a7;
next=NULL;
}
};
PCB *Ready_Queue_Head=NULL;
PCB *Block_Queue_Head=NULL;
//创建了就绪队列和阻塞队列,均包含头结点,以后的节点插入均采取插入排序
void InitQueue()
{
Ready_Queue_Head=(PCB*)malloc(sizeof(PCB));
Ready_Queue_Head->PRIORITY=99999;
Ready_Queue_Head->next=NULL;
Block_Queue_Head=(PCB*)malloc(sizeof(PCB));
Block_Queue_Head->PRIORITY=99999;
Block_Queue_Head->next=NULL;
}
//用于cpu处理完所有进程后释放队列的头结点,避免内存泄露
void FreeQu
动态优先权进程调度算法
最新推荐文章于 2020-11-23 10:37:17 发布