官术网_书友最值得收藏!

Introducing process basics

A running instance of a program is called as process. A program stored in the hard disk or pen drive is not a process. When that stored program starts executing, then we say that process has been created and is running.

Let's very briefly understand the Linux operating system boot-up sequence:

  1. In PCs, initially the BIOS chip initializes system hardware, such as PCI bus, display device drivers, and so on.
  2. Then the BIOS executes the boot loader program.
  3. The boot loader program then copies kernel in memory, and after basic checks, it calls a kernel function called start_kenel().
  4. The kernel then initiates the OS and creates the first process called init.
  5. You can check the presence of this process with the following command:
    $ ps –ef
    
  6. Every process in the OS has one numerical identification associated with it. It is called a process ID. The process ID of the init process is 1. This process is the parent process of all user space processes.
  7. In the OS, every new process is created by a system call called fork().
  8. Therefore, every process has a process ID as well as the parent process ID.
  9. We can see the complete process tree using the following command:
    $ pstree
    

You can see the very first process as init as well as all other processes with a complete parent and child relation between them. If we use the $ps –ef command, then we can see that the init process is owned by root and its parent process ID is 0. This means that there is no parent for init:

Therefore, except the init process, all other processes are created by some other process. The init process is created by the kernel itself.

The following are the different types of processes:

  • Orphan process: If by some chance the parent process is terminated, then the child process becomes an orphan process. The process which created the parent process, such as the grandparent process, becomes the parent of orphan child process. In the last resort, the init process becomes the parent of the orphan process.
  • Zombie process: Every process has one data structure called the process control table. This is maintained in the operating system. This table contains the information about all the child processes created by the parent process. If by chance the parent process is sleeping or is suspended due to some reason and the child process is terminated, then the parent process cannot receive the information about the child process termination. In such cases, the child process that has been terminated is called the zombie process. When the parent process awakes, it will receive a signal regarding the child process termination and the process control block data structure will be updated. The child process termination is then completed.
  • Daemon process: Until now, we had started every new process in a Bash terminal. Therefore, if we print any text with the $ echo "Hello" command, it will be printed in the terminal itself. There are certain processes that are not associated with any terminal. Such processes are called a daemon process. These processes are running in background. An advantage of the daemon process is they are immune to the changes happening to Bash shell, which has created it. When we want to run certain background processes, such as DHCP server and so on, then the daemon processes are very useful.
主站蜘蛛池模板: 松原市| 白城市| 延庆县| 西青区| 西华县| 太康县| 侯马市| 无棣县| 苗栗市| 北碚区| 盐亭县| 新巴尔虎右旗| 昌吉市| 望江县| 化州市| 安顺市| 宝坻区| 淮安市| 邛崃市| 台湾省| 绥芬河市| 称多县| 玉田县| 建湖县| 象山县| 承德市| 龙川县| 贵州省| 新竹县| 黔南| 大埔区| 肃北| 酒泉市| 班玛县| 嵩明县| 湄潭县| 西峡县| 松江区| 涞源县| 贡觉县| 天水市|