Everyday, we see the processes running in our machines. In Windows we can see them in the task manager and in Linux, for example in Ubuntu we can see them either by giving the ps command in the console or by looking the “System Monitor” window. As a computer science student we may have studied about “Process and Threads” in our operating system course. One major point we have to remember while studying OS course is, the processes running in an OS ( say Windows) will exhibit completely a different behavior when compared to a process running in Linux. I came to know the differences when I was reading a book on Window system internals. They mentioned about this at the beginning of the 1st chapter. In this article, after a short definition, I am going to demonstrate a simple difference between the processes running in Windows and as well as in Linux.
A common and a simple definition is “Process is a program in execution”. Some say “Process is a set of tasks which achieves a particular result by consuming the system resources”. Let me put in this way! “Process is a container for a set resources used when executing an instance of a program, where a program is a sequence of instructions”. Typically the points mentioned below are some of the components of a process in Windows,
1. Unique process ID. (PID)
2. Threads (at least one)
3. Private virtual address in which a process is executed and later it will mapped to the physical memory
4.. List of open handles to system resources like files, semaphore and communication ports.
5. Access tokens, which contains information to prevent executing the process from a non privileged user account.
There are some properties which are common for all OS ‘s like they can communicate with other processes using a shared object or through a pipe, they can create threads, child process etc. However there are differences, I would like to tell a simple difference between the processes running in Windows and Linux.
1. In Linux, if the parent process is closed then all the associated child process are forced to exit along with their parent. But still you can make it work like in Windows.
2. In Windows, it is the other way around. Even when you close a parent process the child processes will be continuing with what they were doing.
3. In Windows, the child process will contain only one information ( parent PID ) about their parent. They will not store any information about a process which created their parent process.
To illustrate the above point we will assume there are 3 processes running P1, P2 and P3 where P1 is the parent of P2 and P2 is the parent of P3. As mentioned above the grant child process ( P3 ) will not store any information about process P1, but they keep an information (PID) of their parent process P2. Quite a few of us may not have noticed the difference. Well, will illustrate with an example. First let us start from Windows! Like I said before in point 2, even when you close the parent process, the child process will be continuing to execute as a process with no parent. In other words, it is executes as a parent process with no child process. Now check out this in your windows machine.
1. Open a command prompt. This will be a parent process. Optionally you can give a title for your cmd prompt using the “> title” command. I have given the title as “Parent”.
2. In the same command prompt window, start another application of your choice. I have opened “mspaint” by typing “> start mspaint”. This will be 1st the child process for the parent process cmd.
3. You can see the tree view in the above image, depicting the parent child relation using an application called “Process Explorer”.
4. Now select the cmd task from task manager, right click and select “End process” or just close the cmd application.
5. If you see the above picture, we can notice the mspaint application running perfectly without getting closed. It became a parent with no child process. So this proves point number (2).
Now will see the next difference. For this example also we will create 3 processes namely P1, P2, and P3, where P1 (cmd.exe) is the parent of P2 (cmd.exe) and P2 is the parent of P3(mspaint). Now, here it is,
1. If you terminate the parent process by selecting “End Process Tree” then all the child process will be forced to exit. But closing the parent process by selecting “End Process” will make P2 as the parent process and P3 will be continuing to run.
2. Try this, don’t close P1 now. Close the process P2 ( cmd.exe), the process P3 (mspaint) will be executing as an independent process.
3. Now even when you give “End Process Tree” on process P1, you may see the process P3 will be continuing to run as an independent process. So it’s clear that it is able to run without terminating since it is not holding any information about process P1.
Finally let us do the same with Linux. We will create process 3 process as mentioned above. Here, P1 P2 will be terminator console and P3 will be firefox browser. Try closing the P1 you can see all the process will be closed along with P1.
You should be able to differentiate them now! So this article may not be great, but definitely you may not discussed about it very much. Anyway I found it interesting! 😉