上篇随笔不知何故继续编辑发生卡顿,因此重新开一篇随笔继续整理笔记。
最近开始学习操作系统原理这门课程,特将学习笔记整理成技术博客的形式发表,希望能给大家的操作系统学习带来帮助。同时盼望大家能对文章评论,大家一起多多交流,共同进步!
本篇文章大致内容为:
进程终止(Process Termination)
- Output data from child to parent(via waiting)
- Process‘ resources are deallocated by OS
2. 异常终止:Parent may terminate execution of children processes(abort)
- Child has exceeded allocated resources 子进程需要的资源高于父进程可提供的资源
- Task assigned to child is no longer required 子进程的任务不再需要
- If parent is exiting, in some OSs do not allow child to continue if its parent terminates - cascading termination 若父进程结束,则在某些操作系统中子进程也会终止,层叠终止。
进程间通信(Interprocess Communication)
Independent process 独立进程 不会影响其他进程或被其他进程影响
Cooperating process 协作进程 多个进程一起完成一项任务,其中一个进程的结果可能影响到其他进程或被其他进程所影响
好处: 1. 信息共享
2. 提高计算加速比 Conputation speedup
3. 便于模块化设计 Modularity
4. 便利:单个用户可以同时完成多项任务 individual user works on many tasks simultaneously
数据交换的机制:IPC - mechanism to exchange data * information
下入为消息传递(左图)和共享储存(右图)的结构示意图
生产者-消费者问题 Producer-Consumer Problem
操作系统的范例,生产者生产出消息被消费者所消化。
使用*in和*out两个指针,初始时都设置在系统给进程分配的共享内存空间的最低位,若生产者生产出消息,则将消息放在in指针指向的内存空间,in指针+1;若消费者消化消息,则取出out指针指向的内存空间,out+1.
前驱关系: P --> C : 缓存全空 C-->P : 缓存全满
Insert(): while(((in + 1) % BUFFERSIZE) == out) ; //do nothing
Remove(): while(in == out) ;//do nothing
存在两个问题:
//未完待续
原文:http://www.cnblogs.com/PaulingZhou/p/5326605.html