LinuxQuestions.org
Latest LQ Deal: Latest LQ Deals
Home Forums Tutorials Articles Register
Go Back   LinuxQuestions.org > Forums > Linux Forums > Linux - Newbie
User Name
Password
Linux - Newbie This Linux forum is for members that are new to Linux.
Just starting out and have a question? If it is not in the man pages or the how-to's this is the place!

Notices


Reply
  Search this Thread
Old 01-05-2012, 03:23 AM   #1
vishnu anand
LQ Newbie
 
Registered: Dec 2011
Posts: 12

Rep: Reputation: Disabled
Question Process vs task vs threads


can anyone explain me the exact difference between process task and threads??
thanks in advance!!!
 
Click here to see the post LQ members have rated as the most helpful post in this thread.
Old 01-05-2012, 12:42 PM   #2
theNbomr
LQ 5k Club
 
Registered: Aug 2005
Distribution: OpenSuse, Fedora, Redhat, Debian
Posts: 5,399
Blog Entries: 2

Rep: Reputation: 908Reputation: 908Reputation: 908Reputation: 908Reputation: 908Reputation: 908Reputation: 908Reputation: 908
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.
 
2 members found this post helpful.
Old 01-05-2012, 10:39 PM   #3
vishnu anand
LQ Newbie
 
Registered: Dec 2011
Posts: 12

Original Poster
Rep: Reputation: Disabled
gr8!!! thank you
 
Old 01-06-2012, 12:13 AM   #4
bsat
Member
 
Registered: Feb 2009
Posts: 347

Rep: Reputation: 72
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.
 
Old 01-06-2012, 09:38 AM   #5
theNbomr
LQ 5k Club
 
Registered: Aug 2005
Distribution: OpenSuse, Fedora, Redhat, Debian
Posts: 5,399
Blog Entries: 2

Rep: Reputation: 908Reputation: 908Reputation: 908Reputation: 908Reputation: 908Reputation: 908Reputation: 908Reputation: 908
Quote:
Originally Posted by bsat View Post
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.
 
Old 01-07-2012, 07:25 AM   #6
bsat
Member
 
Registered: Feb 2009
Posts: 347

Rep: Reputation: 72
@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.
 
Old 04-16-2015, 06:33 AM   #7
mrbrklyn
LQ Newbie
 
Registered: Apr 2015
Posts: 1

Rep: Reputation: Disabled
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.

Ruben
 
  


Reply



Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is Off
HTML code is Off



Similar Threads
Thread Thread Starter Forum Replies Last Post
process vs threads grob115 Linux - Newbie 1 10-04-2010 05:04 PM
Is there a way to kill or suspend a thread/task in a multithreaded process ? onewebclick Linux - General 5 09-03-2009 12:04 AM
process and threads jkeertir Linux - Newbie 1 04-16-2009 11:01 AM
Can i find all threads by a process? msbinu Linux - Newbie 1 09-19-2008 12:32 AM
Threads And Process Penguinizer Programming 1 02-18-2003 09:39 PM

LinuxQuestions.org > Forums > Linux Forums > Linux - Newbie

All times are GMT -5. The time now is 07:09 PM.

Main Menu
Advertisement
My LQ
Write for LQ
LinuxQuestions.org is looking for people interested in writing Editorials, Articles, Reviews, and more. If you'd like to contribute content, let us know.
Main Menu
Syndicate
RSS1  Latest Threads
RSS1  LQ News
Twitter: @linuxquestions
Open Source Consulting | Domain Registration