Page 60 - DCAP103_Principle of operating system
P. 60

Unit 2: Process Management-I



            In this scheme, a communication link has the following properties:                    Notes
               •  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.
            Now suppose that processes P1, P2, and P3 all share mailbox A. Process P1 sends a message to
            A, while P2 and P3 each execute a receive from A. Which process will receive the message sent
            by P1? The answer depends on the scheme that we choose:
               •  Allow a link to be associated with at most two processes.
               •  Allow at most one process at a time to execute a receive operation.
               •  Allow the system to select arbitrarily which process will receive the message.

            (that is, either P2 or P3, but not both, will receive the message). The system may identify the
            receiver to the sender.

            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), then we
            distinguish between the owner (who can only receive messages through this mailbox) and the
            user (who can only send messages to the mailbox). Since each mailbox has a unique owner, there
            can be no confusion about who should receive a message sent to this mailbox. When a process
            that owns a mailbox terminates, the mailbox disappears. Any process that subsequently sends
            a message to this mailbox must be notified that the mailbox no longer exists.

            On the other hand, a mailbox owned by the operating system is independent and is not attached
            to any particular process. The operating system then must provide a mechanism that allows a
            process to do the following:
               •  Create a new mailbox.

               •  Send and receive messages through the mailbox.
               •  Delete a mailbox.

            The process that creates a new mailbox is that mailbox’s owner by default. Initially, the owner
            is the only process that can receive messages through this mailbox. However, the ownership
            and receive privilege may be passed to other processes through appropriate system calls. Of
            course, this provision could result in multiple receivers for each mailbox.

            2.5.5 Synchronization
            Communication between processes takes place by calls to send and receive primitives. There
            are different design options for implementing each primitive. 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 resumesoperation.
               •  Blocking receive: The receiver blocks until a message is available.

               •  Nonblocking receive: The receiver retrieves either a valid message or a null.




                                             LOVELY PROFESSIONAL UNIVERSITY                                    53
   55   56   57   58   59   60   61   62   63   64   65