340 likes | 682 Views
Content. MessagesMessages design issuesSynchronizationAddressingMessage transmissionFormatQueuing disciplineReaders/Writers problemUnix synchronization and communicationWindows 2000 synchronization and communication. Inter Process Communication. Inter process data exchange, execution state
E N D
1. CT213 – Inter Process Communication/Synchronization Petronel Bigioi
2. Content Messages
Messages design issues
Synchronization
Addressing
Message transmission
Format
Queuing discipline
Readers/Writers problem
Unix synchronization and communication
Windows 2000 synchronization and communication
3. Inter Process Communication Inter process data exchange, execution state report, results collection is part of inter process communication; it can be done using some shared memory zones, therefore synchronization is required
Semaphores are primitive (yet powerful) tools to enforce mutual exclusion and for process coordination; still, it may be difficult to produce a correct program using semaphores
The difficulty is caused by the fact that wait and signal operations may be scattered throughout a program and is not easy to see an overall effect
4. Messages When a process interacts with another, two main fundamental requirements must be satisfied: communication and synchronization
Message passing provides both of those functions
Message-passing systems come in many forms; this section will provide a general view of typical features found in such systems
The message-passing function is normally provided in the form of primitives:
Send (destination, message)
Receive (source, message)
5. Messages design issues Synchronization
Blocking vs. Non-blocking
Addressing
Direct
Indirect
Message transmission
Through value
Through reference
Format
Content
Length
Fixed
Variable
Queuing discipline
FIFO
Priority
6. Synchronization Send gets executed in a process
Sending process is blocked until the receiver gets the message
Sending process continues its execution in a non blocking fashion
Receive gets executed in a process
If a message has been previously sent, the message is received and execution continues
If there is no waiting message then
Process can be blocked until a message arrives
The process continues to execute, abandoning the attempt to receive
So both the sender and receiver can be blocking or not
7. Synchronization … There are three typical combinations of systems
Blocking send, blocking receive
Both the receiver and sender are blocked until the message is delivered (provides tight sync between processes)
Non-blocking send, blocking receive
The sender can continue the execution after sending a message, the receiver is blocked until message arrives (it is probably the most useful combination)
Non-blocking send, non-blocking receive
Neither party waits
Typically only one or two combinations are implemented
8. Addressing Direct addressing
Send primitive include the identifier of the receiving process
Receive can be handled in two ways
Receiving process explicitly designates the sending process (effective for cooperating processes)
Receiving process is not specifying the sending process (known as implicit addressing); in this case, the source parameter of receive primitive has a value returned when the receive operation has been completed
Indirect addressing
The messages are not sent directly from sender to receiver, but rather they are sent to a shared data structure consisting of queues that temporarily can hold messages; those are referred to as mailboxes.
Two communicating process:
One process sends a message to a mail box
Receiving process picks the message from the mailbox
9. Indirect process communication Indirect addressing decuples the sender form the receiver allowing for greater flexibility. Relationship between sender and receiver: One to one Private communications link to be set up between two processes Many to one Useful for client server interaction; one process provides services to other processes; in this case, the mailbox is known as port One to many Message or information is broadcasted across a number of processes Many to many