代码实现了模拟进程状态转换及其相应PCB内容、组织结构的变化。
#include<iostream>
using namespace std;
typedef struct pcb{
int id;
struct pcb *next;
}pcb;
pcb *ready,*run,*block;
pcb* cre()//创建带头结点的ready队列
{
pcb *head=new pcb;
head->next=NULL;
pcb *q=head;
int n;
cout<<"输入进程数:\n";
cin>>n;
for(int i=0;i<n;i++)
{
pcb *p=new pcb;
cin>>p->id;
p->next=NULL;
q->next=p;
q=p;
}
return head;
}
void ins(pcb *head,pcb *node)//插入节点
{
pcb *p=head;
while(p->next)
{
p=p->