Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

What is the differences and relationships between "process", "threads", "task" and "jobs" in Linux?

Tags:

linux

I'm fairly confused with some of the terms used in Linux when I learn about web backend programming.

  • What is the difference and relationships between "process", "threads", "task" and "jobs" in Linux?
like image 917
TK. Avatar asked May 01 '10 01:05

TK.


People also ask

What is the difference between process task and job?

Job is work that needs to be done. A task is a piece of work that needs to be done. The process is a series of actions that is done for a particular purpose. Job and task define the work to be done, whereas process defines the way the work can be done or how the work should be done.

What is the difference between process thread and task?

The difference between a thread and a process is, when the CPU switches from one process to another the current information needs to be saved in Process Descriptor and load the information of a new process. Switching from one thread to another is simple. A task is simply a set of instructions loaded into the memory.

What are the relationship between threads and processes?

Process means a program is in execution, whereas thread means a segment of a process. A Process is not Lightweight, whereas Threads are Lightweight. A Process takes more time to terminate, and the thread takes less time to terminate. Process takes more time for creation, whereas Thread takes less time for creation.

What is the difference between process and job in Linux?

Answer: A process refers to a program under execution. This program may be an application or system program. Job means an application program and it is not a system program.


2 Answers

The distinction between process and thread is fairly universal to all operating systems. A process usually represents an independent execution unit with its own memory area, system resources and scheduling slot.

A thread is typically a "division" within the process - threads usually share the same memory and operating system resources, and share the time allocated to that process. For example, when you open your Browser and Microsoft Word, each is a different process, but things that happen in the background of each (like animations, refreshes or backups) can be threads.

A job is usually a long-running unit of work executed by a user. The job may be "handled" by one or more processes. It might not be interactive. For instance, instructing the machine to zip a large file or to run some processing script on a large input file would typically be a job. The naming is relatively historic - Mainframes used to process jobs. In UNIX systems, many jobs are started automatically at prescheduled times using cron, so you have the notion of 'cron jobs'.

like image 180
Uri Avatar answered Oct 24 '22 02:10

Uri


So, a process is a single program. It has at least one thread, maybe more. Each thread takes one scheduler slot, but schedulers differ in how they allocate CPU to threads; in any case, the point of threads is to let a process do multiple things in parallel. Threads share system resources of various kinds, especially memory, files and sockets.

Jobs and tasks are unix shell concepts; a job is a process that a shell launched that is still running, either paused or running in the background. There is a long section on 'job control' in the bash manual. Job and task are roughly equivalent concepts.

like image 22
Andrew McGregor Avatar answered Oct 24 '22 00:10

Andrew McGregor