LinuxQuestions.org

LinuxQuestions.org (/questions/)
-   Linux - Newbie (http://www.linuxquestions.org/questions/linux-newbie-8/)
-   -   Process vs task vs threads (http://www.linuxquestions.org/questions/linux-newbie-8/process-vs-task-vs-threads-922161/)

vishnu anand 01-05-2012 03:23 AM

Process vs task vs threads
 
can anyone explain me the exact difference between process task and threads??
thanks in advance!!!

theNbomr 01-05-2012 12:42 PM

In Linux, there is no such thing as a task, at least by any formal definition that I know of.

A process is the basic model used to separate running programs and their resources from all other such programs and the kernel. A process has memory resources allocated by the kernel, and these are private to the process, and protected from all other processes. A process is given time for execution of code in it's code memory space by the kernel.

Within a process, there is at least one thread of execution. Using threads, there can be multiple threads of execution that all share the same code memory space that is private to the process. The threads execute independently, but execute a common code segment. Also shared between threads within a process is the data memory, meaning that process variables are common to all threads within the process.

--- rod.

vishnu anand 01-05-2012 10:39 PM

gr8!!! thank you :):)

bsat 01-06-2012 12:13 AM

A process and a thread are treated in the same fashion in linux, except for some small variations. Hence some times the generic term task is used to refer to process as well as thread.
You can read chapter on process management in http://www.amazon.com/Linux-Kernel-D.../dp/0672329468 for more information.

theNbomr 01-06-2012 09:38 AM

Quote:

Originally Posted by bsat (Post 4567618)
A process and a thread are treated in the same fashion in linux, except for some small variations.

Respectfully disagree. What are those 'small variations'? The OP asked for the 'exact difference'. I'd say there are far more differences than there are similarities. If they are substantially the same, why would we have both, and not simply one or the other?

--- rod.

bsat 01-07-2012 07:25 AM

@rod What I meant was they are treated in a similar fashion in linux . To Linux, a thread is just a special kind of process.
As far as I have read the data structures that handle a process as well as thread are the same in linux.
In linux the same system call clone() creates a thread as well as a process, but the difference lies the flags passed to this system call.
So the term task is some times used in place of the term process.


All times are GMT -5. The time now is 03:44 PM.