Linux - NewbieThis 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
Welcome to LinuxQuestions.org, a friendly and active Linux Community.
You are currently viewing LQ as a guest. By joining our community you will have the ability to post topics, receive our newsletter, use the advanced search, subscribe to threads and access many other special features. Registration is quick, simple and absolutely free. Join our community today!
Note that registered members see fewer ads, and ContentLink is completely disabled once you log in.
If you have any problems with the registration process or your account login, please contact us. If you need to reset your password, click here.
Having a problem logging in? Please visit this page to clear all LQ-related cookies.
Get a virtual cloud desktop with the Linux distro that you want in less than five minutes with Shells! With over 10 pre-installed distros to choose from, the worry-free installation life is here! Whether you are a digital nomad or just looking for flexibility, Shells can put your Linux machine on the device that you want to use.
Exclusive for LQ members, get up to 45% off per month. Click here for more info.
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.
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.
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 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.
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.
LinuxQuestions.org is looking for people interested in writing
Editorials, Articles, Reviews, and more. If you'd like to contribute
content, let us know.