`
jgsj
  • 浏览: 956168 次
文章分类
社区版块
存档分类
最新评论

双语: 进程通信 - 消息传递系统 Message-Passing Systems

 
阅读更多

several methods for logically implementing a link and the send()/receive() operations:

执行一个连接和send()/receive()操作的几个方法:
• Direct or indirect communication

直接或者间接通信
• Synchronous or asynchronous communication

同步和异步通信
• Automatic or explicit buffering

自动和显式缓冲

Under direct communication, each process that wants to communicate must explicitly name the recipient or sender of the communication.

直接通信,每个要求通信的进程都必须显式命名接受者和发送者。

同步定义:
• send(P, message)—Send a message to process P.
• receive(Q, message)—Receive a message from process Q.

异步:

send(P, message)—Send a message to process P.
receive(id, message)—Receive a message from any process.

简直通信更加desirable:

With indirect communication, the messages are sent to and received frommailboxes, or ports.Amailbox can be viewed abstractly as an object into which messages can be placed by processes and fromwhich messages can be removed.

间接通信,信息的发送和接受都是通过邮箱来或者端口实现的。邮箱可以抽象看做是一个对象,进程可以往里面添加信息,里面的信息也可以移除。

two processes can communicate only if they have a shared mailbox. The send() and receive() primitives are defined as follows:

只有两个进程共享一个邮箱才能通信。Send()和receiver()的元操作如下定义:
• send(A, message)—Send a message to mailbox A.
• receive(A, message)—Receive a message from mailbox A.

Now suppose that processes P1, P2, and P3 all share mailbox A. Process P1 sends a message to A, while both P2 and P3 execute a receive() from A.

假设有三个进程P1, P2, P3都共享一个邮箱A。进程P1发送一个信息到A,与此同时P2和P2对A执行一个receive()操作
Which process will receive the message sent by P1?

哪一个进程会接受到P1的信息呢?

The answer depends on which of the following methods we choose:

答案依赖是使用下面哪一种策略:
• Allow a link to be associated with two processes at most.

允许一个链接可以被最多两个进程访问
• Allow at most one process at a time to execute a receive() operation.

最多允许一个进程在一个时刻内执行一个receive()操作
• Allow the system to select arbitrarily which process will receive the message

允许系统按照一定的算法选择其中一个进程接受信息。例如一个任务只需要其中一个进程完成就可以了,没必要两个进程都同时进行。

A mailbox may be owned either by a process or by the operating system.

一个邮箱可以有进程或者系统拥有。
If the mailbox is owned by a process (that is, the mailbox is part of the address space of the process)

邮箱由进程拥有与就是说邮箱是进程地址中的一部分。随着进程结束而结束。

由系统拥有的邮箱可以运行进程做如下操作:
• Create a new mailbox.

创建一个新的邮箱
• Send and receive messages through the mailbox.

通过邮箱发送和接受信息
• Delete a mailbox.

删除一个邮箱。

进程创建一个新的邮箱就是这个邮箱的拥有者。

However, the ownership and receiving privilege may be passed to other processes through appropriate system calls.

但是通过适当的系统调用,拥有者和接受者的特权也可以传递给其他进程。

Synchronization

同步方法
• Blocking send. The sending process is blocked until the message is received by the receiving process or by the mailbox.

发送阻止。 阻止发送进程,直到消息被接受进程接受或者被邮箱接受了。
• Nonblocking send. The sending process sends the message and resumes operation.
不阻止发送。发送进程发送消息和恢复操作。
• Blocking receive. The receiver blocks until a message is available.

阻止接受。阻止接受者,直到消息可用。
• Nonblocking receive. The receiver retrieves either a valid message or a null.

不阻止接受。接受者接收到可用消息或者是空消息。

分享到:
评论

相关推荐

Global site tag (gtag.js) - Google Analytics