Page 62 - DCAP403_Operating System
P. 62

Unit 4: Process Management





                                   Figure 4.5: Process State Transitions                        Notes
                      New                                      Terminated
                                                      Exit
                                     Interrupt
                    Admitted
                                      Dispatch
                              Ready             Running
                      I/O or event   I/O or
                      completion     wait event

                              Blocked
                                       Ready queue
                                                              Processor



                                           Blocked queue




          4.3.3 Process Termination

          Processes terminate in one of two ways:
          1.   Normal Termination occurs by a return from main or when requested by an explicit call to
               exit.
          2.   Abnormal Termination occurs as the default action of a signal or when requested by
               abort.
          3.   On receiving a signal, a process looks for a signal-handling function. Failure to  fi nd  a
               signal-handling function forces the process to call exit, and therefore to terminate.
          4.   A parent may terminate the execution of one of its children for a variety of reasons, such as
               these:
               (a)   The child has exceeded its usage of some of the resources that it has been allocated.
                    This requires the parent to have a mechanism to inspect the state of its children.

               (b)   The task assigned to the child is no longer required.
               (c)   The parent is exiting, and the operating system does not allow a child to continue
                    if its parent terminates. On such systems, if a process terminates (either normally
                    or abnormally), then all its children must also be terminated. This phenomenon,
                    referred to as cascading termination, is normally initiated by the operating system.

          4.4 Cooperating Processes

          Concurrent processes executing in the operating system allows for the processes to cooperate
          (both mutually or destructively) with other processes. Processes are cooperating if they can affect
          each other. The simplest example of how this can happen is where two processes are using the
          same file. One process may be writing to a file, while another process is reading from the fi le; so,


          what is being read may be affected by what is being written. Processes cooperate by sharing data.
          Cooperation is important for several reasons:
          Information Sharing

          Several processes may need to access the same data (such as stored in a fi le.)



                                           LOVELY PROFESSIONAL UNIVERSITY                                    55
   57   58   59   60   61   62   63   64   65   66   67