chapter4processes进程内容摘要:

on the size of the 没有对缓冲区大小的限制  boundedbuffer assumes that there is a fixed buffer 缓冲 对缓冲区大小作了限定 2020年 9月 26日 12时 27分 Operating System Concepts BoundedBuffer – SharedMemory Solution  The Buffer may either be provided by the operating system through the use of an interprocessmunication (IPC) facility (Sec ) , or by explicitly coded by the application programmer with the use of shared memory .  SharedMemory Solution to the BoundedBuffer problem : Shared data define BUFFER_SIZE 10 Typedef struct { . . . } item。 item buffer[BUFFER_SIZE]。 int in = 0。 int out = 0。 2020年 9月 26日 12时 27分 Operating System Concepts BoundedBuffer – Producer Process Producer : item nextProduced。 while (1) { produce an item in nextProduced。 while (((in + 1) % BUFFER_SIZE) == out)。 /* do nothing */ buffer[in] = nextProduced。 in = (in + 1) % BUFFER_SIZE。 } Solution is correct, but can only use BUFFER_SIZE1 elements Buffer is full Why? How to improve? 2020年 9月 26日 12时 27分 Operating System Concepts BoundedBuffer – Consumer Process Consumer : item nextConsumed。 while (1) { while (in == out)。 /* do nothing */ nextConsumed = buffer[out]。 out = (out + 1) % BUFFER_SIZE。 consume the item in nextConsumed。 }  In Chap 7 we discuss how synchronization among cooperating processes . Buffer is empty 2020年 9月 26日 12时 27分 Operating System Concepts Interprocess Communication (IPC) 进程间通信  IPC provides a Mechanism for processes to municate and to synchronize their actions without sharing the same address space . IPC提供 无须共享相同地址空间可用于进程通信的机制,同步其间的活动  IPC is best provided by a messagepassing system .  signal( 信号机制) :给其他进程发送异步事件信号。 如: kill –9 pid :向 pid 进程发送 9号信号(无条件终止) kill –l : 显示系统中所有的信号 ls –l | wc –l :求出当前目录下的文件数  pipe( 管道技术) :一个进程的输出作为另外一个进程的输入,实现相关进程(如父子进程)通信,可看作一个临时文件。 如:  无名管道( pipe): ls –l | grep ‗^d‘, 实现相同父进程的子进程间通信。  命名管道 (named pipe, FIFO): 是有名字的管道,在 OS中作为一个对象(文件,即FIFO文件)存在,实现任何进程间通信  mkfifo pipename  ls –l pipename amp。 wc –l pipename 2020年 9月 26日 12时 27分 Operating System Concepts MessagePassing System消息传递系统  Message system – processes municate with each other without resorting to shared variables. 消息系统 进程间通信无须对共享变量进行再分类  IPC facility provides two operations:IPC提供两个操作 : send(message) – message size fixed or variable 发送 固定或可变大小消息 receive(message) 接受 2020年 9月 26日 12时 27分 Operating System Concepts MessagePassing System (Cont.)  If P and Q wish to municate, they need to: 若 P与 Q要通信,需要 : establish a munication link between them 建立通信连接 exchange messages via send/receive 通过 send/receive交换消息  Implementation of munication link通信连接的实现 physical (., shared memory, hardware bus) 物理的(如,共享存储,硬件总线)  logical (., logical properties) 逻辑的(如,逻辑特性) 2020年 9月 26日 12时 27分 Operating System Concepts MessagePassing System (Cont.)  several method for implementing a link and the send / receive operation : 实现链接的几种方法和发送 /接收操作 : Direct or indirect munication 直接或间接的通信 Symmetric or asymmetric munication 同步或异步通信 Automatic or explicit buffering 自动或显式的缓冲 Send by copy or send by reference 通过拷贝或通过引用发送 Fixedsized or variablesized message 固定大小或可变大小的消息 2020年 9月 26日 12时 27分 Operating System Concepts Implementation Questions实现中的问题  How are links established?连接如何建立。  Can a link be associated with more than two processes?连接可同多于两个的进程相关吗。  How many links can there be between every pair of municating processes? 每对在通信进程有多少连接。  What is the capacity of a link?一个连接的容量是多少。  Is the size of a message that the link can acmodate fixed or variable? 连接可使用的固定或可变消息的大小。  Is a link unidirectional or bidirectional? 连接是无向的还是双向的。 2020年 9月 26日 12时 27分 Operating System Concepts Naming命名 Direct Communication直接通信  Processes must name each other explicitly: 进程必须互相显式的命名 send (P, message) – send a message to process P 向进程 P发消息 receive(Q, message) – receive a message from process Q 从进程 Q收消息 2020年 9月 26日 12时 27分 Operating System Concepts Direct Communication直接通信  Properties of munication link通信连接的特性 Links are established A link is associated with exactly one pair of municating processes. 连接精确的与一对在通信的进程相关 Between each pair there exists exactly one link. 在每一对之间就存在一个连接 The link may be unidirectional, but is usually bidirectional. 连接可以单向的,但通常是双向的 2020年 9月 26日 12时 27分 Operating System Concepts Indirect Communication 间接通信  Messages are directed and received from mailboxes (also referred to as ports). 消息导向至信箱并从信箱接收(被视作端口) Each mailbox has a unique id. 每一个信箱有一个唯一的 id Processes can mun。
阅读剩余 0%
本站所有文章资讯、展示的图片素材等内容均为注册用户上传(部分报媒/平媒内容转载自网络合作媒体),仅供学习参考。 用户通过本站上传、发布的任何内容的知识产权归属用户或原始著作权人所有。如有侵犯您的版权,请联系我们反馈本站将在三个工作日内改正。