C++编程(关于操作系统的进程问题)

来源:百度知道 编辑:UC知道 时间:2024/06/15 21:04:41
1.采用动态或静态方法生成一棵进程树(进程树>=20)
2.设计撤消进程算法
3.实现进程撤消函数,采用级联方式撤消
4.可动态撤消进程
5.可动态观察进程树的情况
6.测试程序并得到正确结果

是自己上机实验
和你的要求也许不知道一样但是你可以看看啊
模拟进程调度算法:
用C++的代码描述:
#include "iostream.h"

//define pcb
typedef struct pcb
{
char name[10]; //进程名
char state; //状态w(就绪)r(运行)f(结束)
int id; //id号
int super; //优先级
int ntime; //需运行的时间
int rtime; //已运行的时间
struct pcb *next;
}*pcb1;

pcb1 s,w;//define two publiced linknode ,one is s(ready queue),one is w(blocked queue)

//initialize two queues
void init(pcb1 &r)
{
r=NULL;//both queues is the kind of head index
}

//print the information of the ready queue
void print()
{pcb1 p;
cout<<"您现在查看的是就绪队列的信息:" ;
cout<<"进程号 "<<"进程名 "<<"优先级 "<<"状态"<<"已运行时间 "<<"需运行时间"<<endl;
for(p=s;p!=NULL;p=p->next)
{
cout<<p->id<<" "<&