网站大量收购独家精品文档,联系QQ:2885784924

UNIX进程管理【免费3天-ppt】.ppt

  1. 1、本文档共65页,可阅读全部内容。
  2. 2、原创力文档(book118)网站文档一经付费(服务费),不意味着购买了该文档的版权,仅供个人/单位学习、研究之用,不得用于商业用途,未经授权,严禁复制、发行、汇编、翻译或者网络传播等,侵权必究。
  3. 3、本站所有内容均由合作方或网友上传,本站不对文档的完整性、权威性及其观点立场正确性做任何保证或承诺!文档内容仅供研究参考,付费前请自行鉴别。如您付费,意味着您自己接受本站规则且自行承担风险,本站不退款、不进行额外附加服务;查看《如何避免下载的几个坑》。如果您已付费下载过本站文档,您可以点击 这里二次下载
  4. 4、如文档侵犯商业秘密、侵犯著作权、侵犯人身权等,请点击“版权申诉”(推荐),也可以打举报电话:400-050-0827(电话支持时间:9:00-18:30)。
查看更多
UNIX进程管理【免费3天-ppt】

Unix 进程管理;1.进程的概念;2.UNIX进程结构;3.UNIX进程上下文;进程PCB(proc + user);进程PCB(proc + user);系统共享正文段表 text;;4. 进程状态;进程状态(续);5. 进程调度;进程调度(续);Swtch流程图;6. 进程控制;fork---创建进程;fork();;fork例;父;exec-执行文件;exec(文件名,参数表);头 正文段 数据段 工作区;wait--等待子进程结束 exit---终止进程;exit(int status);wait(int * stat);shell程序;上机作业;实例:UNIX_wait;main() { int local,i; pid_t child; if ((child=fork()) == -1) { // 创建失败 printf(Fork Error.\n); } if (child == 0) {// 子进程 printf(Now it is in child process.\n); if (execl(/home/xyong/work/ttt,ttt,NULL) == -1) { // 加载程序失败 perror(Error in child process); } global=local + 2; exit(); }; // 父进程 printf(Now it is in parent process.\n); for (i=0; i10; i++) { sleep(2); printf(Parent:%d\n,i); if (i==2) { if ((child=fork()) == -1) { // 创建失败 printf(Fork Error.\n); } if (child == 0) {// 子进程 printf(Now it is in child process.\n); if (execl(/home/xyong/work/ttt,ttt,NULL) == -1) { // 加载程序失败 perror(Error in child process); } global=local + 2; exit(); } }; if (i==3) { pid_t temp; temp=wait(NULL); printf(Child process ID: %d\n, temp); } } global=local + 1; exit(); };程序test.c;7. 进程间通信 (IPC, INTER-PROCESS COMMUNICATION);U7.1 进程间通信的类型;直接通信和间接通信;U7.2 信号(signal);1.信号类型;2.对信号的处理;信号例;U7.3 共享存储区(shared memory);共享存储区系统调用;main() {int shmid;*p,i; char * shmaddr; shmid=shmget(KEY,K, 0777|IPC_CREAT); shmaddr=shmat(shmid,0,0); p=(int *) shmaddr; for(i=0;iK;i++) *p++ = i*i; shmdt(shmid); shmctl(shmid,IPC_RMID,0); ….... };U7.4 消息(message);UNIX消息;消息的系统调用格式及使用;main() {int msgid,p,i; struct msgbuf msg; msgid=msgget(KEY, 0777|IPC_CREAT); for(;;){ msgrcv(msgid,msg,256,1,0); p=(int*)msg.mtext; msg.mtype=*p; msg.mtext=“OK”; msgsnd(msgid,msg,2,0);} ….. };U7.5 Unix 信号量(Semaphore);信号量APIs;信号量APIs(cont.);用unix信号量实现P、V操作 producer--concumer;用unix信号量实现P、V操作 producer--concumer;用unix信号量实现进程同步例 producer--concumer;用unix信号量实现进程同步例 p1,p2共享printer and plotter;U7.6 管道(pipe);1.

文档评论(0)

qiwqpu54 + 关注
实名认证
内容提供者

该用户很懒,什么也没介绍

1亿VIP精品文档

相关文档