Linux Processes
We always come across the term ‘‘Process’ in various Linux tutorials. In this tutorial, I will explain what the process is and how it works. If I want to make my passport but I don’t know what is the process. I will go to the inquiry window and ask about it. Process is nothing but carrying out a task. My task is to make passport and process is how to make passport.
Process is an instance of program code in execution within the operating system. In computer machine, various applications run at the same time and they share the resource like printer, disk drive etc. Let’s discuss one more example. I want to print some documents from computer and the printer is connected with my computer. My task is to print the documents and process is some code which allocates documents to printer and asks to print it. These are generally created when we want to use them and are destroyed after use. Processes have more or less significant life and generate one or more child processes. In terms of kernels, the purpose of process acts as entity to which system resource are allocated.
Each and every process is created from some initial point in system called parent process. Child Process copies the address from parents and run in same address space. In Linux, some processes are light weight processes which support multithreading application.
Process includes CPU’s register, program counter, stack, heap and data memory and other resources. It can also share the file and hold the data on physical memory. Two processes also synchronize with each other and share common data. Each process has its own process ID. In System, some processes are running, some are in waiting list and some are stopped. Operating system needs to carry out whatever is done in a process. *(line is not clear)
Process Descriptor
Process descriptor tracks the process and gives a clear picture of what the process is doing. Each process has its own process descriptor which manages the process. It provides the information of process like whether process is running on CPU or waiting, priority of process, which address space is assigned to it, which file is allocated to address etc. It is a wide data structure which contains all the information related to a single process. In Linux system, struct task_struct is structure whose field contains all information of single process. Each process descriptor also contains several pointers to another data structure. Another data structure refers to a specific process resource used by process.
Fig. 1: Overview of Process Descriptor
Process State
State describes what is happening to the process. It consists of array of flags which provide the state of process. The state field of the process descriptor describes the current condition of the process like running, blocked, interrupting or waiting etc. Each process is in one state of process. Exactly one flag is set for each process and another flags are clear. One of the values of flag is set from following flag:
Fig. 2: Overview of Process State
TASK_RUNNING – This flag describes either a process being executed on CPU or waiting to be executed. This state can be run both in user space and kernel space.
TASK_INTERRUPTIBLE – The process (blocked or suspended), waits for some conditions to exist. It would be executed and kernel change process’s state from TASK_INTERRUPTIBLE to TASK_RUNNING when some condition becomes true.
TASK_UNINTERRUPTIBLE – This state is identical to TASK_INTERRUPTIBLE except that it does not run on interrupt. This is used in situations where the process must wait without interruption or wait for quick occurrence of hardware condition. For example, the process opens the device file and corresponding device driver starts probing with hardware device. It is not interruptable until probing is not complete. TASK_UNINTERRUPTIBLE is less usable than TASK_INTERRUPTIBLE.
TASK_ZOMBIE – Process execution is terminated but parent process is not aware about the termination of child process, this time TASK_ZOMBIE holds the information of child process. The task has been terminated, but its parent has not yet issued a wait4 ( ) system call and wants to access child’s information.
TASK_STOPPED – The process execution has stopped after complication of process. The process enters in this stage after receiving any one of the signals from SIGSTOP, SIGTSTP, SIGTTIN, or SIGTTOU. After receiving any signal mentioned above, task stops running.
Filed Under: Tutorials
Questions related to this article?
👉Ask and discuss on EDAboard.com and Electro-Tech-Online.com forums.
Tell Us What You Think!!
You must be logged in to post a comment.