Difference: Program VS Process VS Thread

Here are the definitions and the explanations from Wikipedia.

Program:

A computer program, or just a program, is a sequence of instructions, written to perform a specified task with a computer.

http://en.wikipedia.org/wiki/Computer_program

Process:

A process is an instance of a computer program that is being executed. It contains the program code and its current activity. Depending on the operating system (OS), a process may be made up of multiple threads of execution that execute instructions concurrently.

A computer program is a passive collection of instructions; a process is the actual execution of those instructions. Several processes may be associated with the same program; for example, opening up several instances of the same program often means more than one process is being executed.

http://en.wikipedia.org/wiki/Process_(computing)

Thread:

A thread of execution is the smallest sequence of programmed instructions that can be managed independently by a scheduler, which is typically a part of the operating system. The implementation of threads and processes differs between operating systems, but in most cases a thread is a component of a process. Multiple threads can exist within the same process and share resources such as memory, while different processes do not share these resources. In particular, the threads of a process share its instructions (executable code) and its context (the values of its variables at any given moment).

http://en.wikipedia.org/wiki/Thread_(computing)

As you can see, you can consider a program is just a sequence of instruction stored in the secondary memory. It is not necessary to be loaded to RAM and not necessary to be executed.

However, for a process, it is a piece of program that is loaded, being executing and running in the system. Every instructions would probably be executed and the values of the declared variables would be charged accordingly.

In the pass, 1 process can only execute 1 task at the same time. But, thread gives a process the ability of executing various tasks at the same time, so that it may get the input data and calculate the result meanwhile. Thus, you may find several threads in the same process. Each thread has its own stack. In a process, or a program, there is only 1 thread by default but one may normally create multiple threads by “pthread” library, #include in C/C++. If you create a new thread, it points to a new function in the code. But they can access the other functions, Macros, global variables and so on.

 

You may check out more here:
https://ksearch.wordpress.com/2010/09/12/program-vs-process-vs-thread/

Comments

comments

Leave a Comment

Your email address will not be published. Required fields are marked *

You may use these HTML tags and attributes: <a href="" title=""> <abbr title=""> <acronym title=""> <b> <blockquote cite=""> <cite> <code class="" title="" data-url=""> <del datetime=""> <em> <i> <q cite=""> <strike> <strong> <pre class="" title="" data-url=""> <span class="" title="" data-url="">