-   Linux - Newbie (
-   -   Process vs task vs threads (

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 for more information.

theNbomr 01-06-2012 09:38 AM


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.

mrbrklyn 04-16-2015 06:33 AM

Previous Answer is not correct
The previous answer that says there is no such thing as a TASK in GNU/Linux is FACTUALLY wrong.

Actually, EVERYTHING in GNU/Linux is a task.
Everything swapped to a CPU is an task_entity. A task is scheduled onto the scheduler through the kernel command schedule() and pick_up_next_task()

Threads are tasks
Processes are tasks with a single thread... more or less.

A more detailed answer requires a lot more study then this little box can provide.

I also recommend the Book anotated earlier by Robert Love.


All times are GMT -5. The time now is 11:52 AM.