Page 259 - DCAP403_Operating System
P. 259

Operating System




                    Notes             9450 pa S 0:01 -Tcsh (Tcsh)
                                      9501 pa T 0:00 less csh.1
                                      9503 pa R 0:00 ps
                                      kill 9501
                                   This kills process number 9501. Notice that the ps command which is entered to check on the
                                   process ID’s has the latest process number.
                                   To kill a process that refuses to die:
                                   kill -9 9352
                                   This makes a certain kill of process number 9352.
                                   To kill a background job:
                                   jobs
                                   [1] + Running xterm -g 70x55
                                   kill %1
                                   [1] Done xterm -g 70x55
                                   This kills job number 1 (one); the only job that is currently running.
                                   To kill more than one process:

                                   kill 8939 9543
                                   This kills processes 8939 and 9543.
                                   It is important to note that the kill command does not perform only negative actions. It can also
                                   be used to restart processes, and to keep processes running, even after a logout.
                                   Understanding the init Processes


                                   [init] is the most important process in Linux. All processes are derived from the init process and
                                   can trace their roots back to init. [init] always has a PID of 1 and is owned by root. The [init]
                                   process is used to start other processes and must be running for the system to operate. In a later
                                   article we will examine the boot process. Here [init] will be discussed in much more detail.

                                   Parent Processes

                                   Every process has a parent process, with the exception of [init], whose parent process ID (PPID)
                                   is 0. It is important to understand the effects of killing a process, especially if that process has
                                   spawned child processes.
                                      Sidebar…for all you parent process’s out there

                                   When you kill a parent process, without first killing the child procesi, then you have created
                                   orphans. Orphans will generally cause performance decreases as they are taking up resources,
                                   but not doing anything. Additionally, they usually do not self terminate, as that task can often be
                                   left up the parent. To ensure that you do not create orphans, make sure that no child processes
                                   exist when you kill the parent. This can be determined by reviewing the output of the -l switch of
                                   the ps command. Compare the PID and PPID columns.

                                   13.4 Process Scheduling

                                   All processes run partially in user mode and partially in system mode. How these modes are
                                   supported by the underlying hardware differs but generally there is a secure mechanism for




          252                              LOVELY PROFESSIONAL UNIVERSITY
   254   255   256   257   258   259   260   261   262   263   264