Page 116 - DCAP403_Operating System
P. 116

Unit 6: Process Synchronization




          6.4 Monitors                                                                          Notes

          A monitor is a software synchronization tool with high-level of abstraction that provides a
          convenient and effective mechanism for process synchronization. It allows only one process to
          be active within the monitor at a time. One simple implementation is shown below.

          monitor monitor_name
          {
              // shared variable declarations
              procedure P1 (…) { …. }
              …
              procedure Pn(…) {……}
              Initialization code ( ….) { …}
              …
          }

          6.5 Deadlock

          Deadlock occurs when you have a set of processes [not necessarily all the processes in the system],
          each holding some resources, each requesting some resources, and none of them is able to obtain
          what it needs, i.e. to make progress. Those processes are deadlocked because all the processes
          are waiting. None of them will ever cause any of the events that could wake up any of the other
          members of the set, and all the processes continue to wait forever. For this model, I assume that
          processes have only a single thread and that there are no interrupts possible to wake up a blocked
          process. The no-interrupts condition is needed to prevent an otherwise deadlocked process from
          being awakened by, say, an alarm, and then causing events that release other processes in the set.
          In most cases, the event that each process is waiting for is the release of some resource currently
          possessed by another member of the set. In other words, each member of the set of deadlocked
          processes is waiting for a resource that is owned by another deadlocked process. None of the
          processes can run, none of them can release any resources, and none of them can be awakened.
          The number of processes and the number and kind of resources possessed and requested are
          unimportant. This result holds for any kind of resource, including both hardware and software.

                                  Figure 6.4: Processes are in Deadlock Situation


                                Waiting    Resource     Owned
                                 for X        X          by B




                                Process                Process
                                  A                      B



                                           Resource
                               Owned          Y        Waiting
                                by A                    for Y









                                           LOVELY PROFESSIONAL UNIVERSITY                                   109
   111   112   113   114   115   116   117   118   119   120   121