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

Introducing process basics

A running instance of a program is called a 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, and display device drivers.
  2. Then the BIOS executes the boot loader program.
  1. The boot loader program then copies the kernel in the memory and, after basic checks, it calls a kernel function start_kernel().
  2. The kernel then initializes the OS and creates the first process called init.
  3. You can check the presence of this process with the following command:
    $ ps -ef  
  1. 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.
  2. In the Linux OS, every new process is created by a system call called fork().
  3. Therefore, every process has a process ID, as well as the parent process ID.
  4. 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 the root and its parent process ID is 0. This means that there is no parent for init:

Therefore, with the exception of 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 that created the parent process, such as the grandparent process, becomes the parent of the orphan child process. As a 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 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 or other 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 have started every new process in a Bash Terminal. Therefore, if we print any text with the $ echo command, it will be printed in the Terminal itself. There are certain processes that are not associated with any Terminal. Such a process is called a daemon process. These processes are running in the background. An advantage of the daemon process is that it is immune to the changes happening to the Bash shell that has created it. When we want to run certain background processes, such as a DHCP server, then the daemon process is very useful.
主站蜘蛛池模板: 东山县| 肃宁县| 衢州市| 民丰县| 洛南县| 绥江县| 德兴市| 突泉县| 英德市| 盘山县| 邻水| 河津市| 姚安县| 郴州市| 林口县| 綦江县| 鄂伦春自治旗| 道真| 安乡县| 洛浦县| 兰溪市| 正宁县| 定襄县| 慈溪市| 肥西县| 绍兴市| 平潭县| 仙桃市| 黎平县| 平乐县| 嘉义市| 土默特左旗| 建水县| 葵青区| 崇文区| 寿阳县| 汉沽区| 塔城市| 个旧市| 兰考县| 金坛市|