资源描述:
《进程的创建与控制撤销.doc》由会员上传分享,免费在线阅读,更多相关内容在行业资料-天天文库。
1、进程的创建与控制撤销学院:软件学院班级:1402成员:冯信瑜刘杨马尚玮一.进程创建,控制及撤销的源代码#include"conio.h"#include"stdio.h"#include"stdlib.h"structjincheng_type{intpid;intyouxian;intdaxiao;intmsg;intlive;};structjincheng_typeneicun[20],waicun[20];intshumu=0,pid_1;create(){if(shumu>=20){printf("内存已满,请先结束
2、或换出进程");}Else{printf("请输入新进程的pid");scanf("%d",&neicun[shumu+1].pid);printf("请输入新的进程的优先级");scanf("%d",&neicun[shumu+1].youxian);printf("请输入新的进程的大小");scanf("%d",&neicun[shumu+1].daxiao);printf("请输入新的进程的消息");scanf("%d",&neicun[shumu+1].msg);neicun[shumu
3、+1].live=1;shumu++;}returnneicun[shumu-1].live;}viewrun(){intvpid;printf("请输入进程的pid");scanf("%d",&vpid);if(vpid>0&&vpid<=20&&neicun[vpid].live==1){printf("进程的pid是:%d",neicun[vpid].pid);printf("进程的优先级是:%d",neicun[vpid].youxian);printf("进程的大小是:%d",neicun
4、[vpid].daxiao);printf("进程的消息是:%d",neicun[vpid].msg);}else{printf("所查看运行进程不存在");}printf("请按回车退出查看");vpid=getch();}huanchu(){intpid1,pid2;charc;printf("请输入第一个替换进程的pid");scanf("%d",&pid1);printf("请输入第二个替换进程的pid");scanf("%d",&pid2);if(pid1>0&&pid1<=20&&n
5、eicun[pid1].live==1){if(neicun[pid1].youxian>neicun[pid2].youxian){waicun[20].pid=neicun[pid1].pid;waicun[20].youxian=neicun[pid1].youxian;waicun[20].daxiao=neicun[pid1].daxiao;waicun[20].msg=neicun[pid1].msg;neicun[pid1].pid=neicun[pid2].pid;neicun[pid1].youxian=neic
6、un[pid2].youxian;neicun[pid1].daxiao=neicun[pid2].daxiao;neicun[pid1].msg=neicun[pid2].msg;neicun[pid2].pid=waicun[20].pid;neicun[pid2].youxian=waicun[20].youxian;neicun[pid2].daxiao=waicun[20].daxiao;neicun[pid2].msg=waicun[20].msg;printf("替换完成");printf("被替换进程的
7、pid是:%d",waicun[20].pid);printf("被替换进程的youxian是:%d",waicun[20].youxian);printf("被替换进程的daxiao是:%d",waicun[20].daxiao);printf("被替换进程的msg是:%d",waicun[20].msg);}else{printf("进程优先级不够大");}}else{printf("所查看运行进程不存在");}printf("请按回车退出换出进程");c=getche();return;}
8、kill(){intkpid;printf("请输入进程的pid");scanf("%d",&kpid);if(kpid>0&&kpid<20&&neicun[kpid].live==neicun[kpid].live=0;}return;