文档详情

操作系统课程设计--进程管理.doc

发布:2018-12-13约6.58千字共9页下载文档
文本预览下载声明
#includestdio.h #includestdlib.h #includestring.h #define NULL 0 int shumu=0; //进程的内容结构体 struct node { int a; char ch; }; //进程PCB结构体 struct jincheng { int pid; int youxian; float luntime; float zhantime; char zhuangtai;//a表示执行,b表示动态就绪 node *neirong; struct jincheng *next; }; struct jincheng *neijin,*neizhi,*p,*q; //换出进程函数 void huanchu(int a) { p=neijin; while(p-pid!=ap!=NULL) { q=p; p=p-next; } if(p==NULL) { printf(该进程不在内存里!\n); return; } if(p==neijin) { neijin=neijin-next; } else { q-next=p-next; } } //杀死正在运行进程函数 void shasi() { neizhi-next=NULL; printf(运行的进程已经杀死!\n); return; } //创建新进程后与正在运行进程比较优先级并根据优先级判断谁该占用处理机 int bijiao() { int i,j; p=neijin; while(p!=NULL) { q=p; p=p-next; } i=q-youxian; j=neizhi-next-youxian; if(ij) { p=neijin; if(p==q) { neijin=neizhi-next; p-neirong=(node*)malloc(sizeof(node)); p-neirong-a=9; p-neirong-ch=c; neizhi-next=p; return 1; } else{ while(p-next!=q) { p=p-next; } p-next=neizhi-next; q-neirong=(node*)malloc(sizeof(node)); q-neirong-a=9; q-neirong-ch=c; neizhi-next=q; neizhi-next-next=NULL; return 1; } } else return -1; } void main() { int zhixing(); void shasi(); void chakan(); void tongxing(int); neizhi=(jincheng*)malloc(sizeof(jincheng)); neizhi-next=NULL; neijin=(jincheng*)malloc(sizeof(jincheng)); neijin-next=NULL; neijin-pid=1; neijin-youxian=6; neijin-luntime=3.5; neijin-zhantime=3; neijin-neirong=(node*)malloc(sizeof(node)); neijin-neirong=NULL; neijin-zhuangtai=b; shumu++; p=(jincheng*)malloc(sizeof(jincheng)); p-next=neijin-next; neijin-next=p; p-pid=2; p-youxian=5; p-luntime=3.5; p-zhantime=3; p-neirong=(node*)malloc(sizeof(node)); p-neirong=NULL; p-zhuangtai=b; shumu++; q=(jincheng*)malloc(sizeof(jincheng)); q-next=p-next; p-next=q; q-pid=3; q-youxian=4; q-luntime=3.5; q-zhantime=3; q-neirong=(node*)malloc(sizeof(node)); q-neirong=NULL; q-z
显示全部
相似文档