Presentation is loading. Please wait.

Presentation is loading. Please wait.

Typically for using the shared memory the processes should:

Similar presentations


Presentation on theme: "Typically for using the shared memory the processes should:"— Presentation transcript:

1 Typically for using the shared memory the processes should:
Shared Memory Systems Typically for using the shared memory the processes should: Establish (allocate) a region of shared memory Memory resides in the address space of the process creating the shared memory segment Other processes that wish to communicate using this shared memory segment must attach it to their address space Shared memory requires that two or more processes agree to remove the address space protection restriction They can then exchange information by reading and writing data in the shared areas After finishing the transfer the memory should be detached. Deallocate the shared memory.

2 Shared Memory Systems example
A shared-memory solution to the bounded-buffer problem

3 Shared Memory Systems example
Producer and Consumer behavior.

4 Message Passing Systems
Message passing provides a mechanism to allow processes to communicate and to synchronize their actions without sharing the same address space (buffer is provided by OS). Message passing is particularly useful in a distributed environment where the communicating processes may reside on different computers connected with a network. If processes P and Q want to communicate a communication link (logical) must be established between them they must use the mechanisms of sending messages to and receiving messages from each other. must have a way to refer to each other (naming). They can use either direct or indirect communication.

5 Direct Symmetric Communication
Direct Communication Processes must name each other explicitly: l send (P, message) – send a message to process P l receive(Q, message) – receive a message from process Q n Properties of communication link l Links are established automatically l A link is associated with exactly one pair of communicating processes l Between each pair there exists exactly one link l The link may be unidirectional, but is usually bi-directional Direct Symmetric Communication

6 Direct Asymmetric Communication

7 Indirect Communication
Processes can communicate only if they share a mailbox or port (with unique identification): l send (A, message) – send a message to mailbox A l receive (A, message) – receive a message from mailbox A n Properties of communication link A link is established between a pair of processes only if both members of the pair have a shared mailbox. A link may be associated with more than two processes. A number of different links may exist between each pair of communicating processes, with each link corresponding to one mailbox. The link may be unidirectional or bi-directional

8 Indirect Communication
Mailbox owner could be the process (mailbox attached to it). Mailbox could be created deleted with the process. Ownership could be transferred to the other process. Mailbox owner could be OS. The process will request creation or deletion of mailbox Send and receive messages through the mailbox

9 Message Synchronization
Message passing may be either blocking or nonblocking-also known as synchronous and asynchronous. 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. Different combinations of send and receive are possible. When both the send and receive are blocking, we have a rendezvous between the sender and the receiver.

10 Message Buffering Whether the communication is direct or indirect,
messages exchanged by communicating processes reside in a temporary queue. Basically, such a queue can be implemented in three ways: No buffering Zero capacity: The queue has maximum length 0 thus, the link cannot have any messages waiting in it In this case, the sender must block until the recipient receives the message. Automatic buffering: Bounded capacity: The queue has finite length n thus, at most n messages can reside in it. If the link is full, the sender must block until space is available in the queue. Unbounded capacity: The queue has potentially infinite length thus, any number of messages can wait in it. The sender never blocks.


Download ppt "Typically for using the shared memory the processes should:"

Similar presentations


Ads by Google