Differences between processes, programs, and threads

Source: Internet
Author: User

Differences between processes, programs, and threads

1. Differences

① A Program is an ordered set of commands and data. It has no running meaning and is a static concept. A process is an execution process of a program on the processing machine. It is a dynamic concept.

② The program can be used as a software material for a long time, and the process has a certain life cycle. The program is permanent and the process is temporary.

③ The process can describe concurrency more realistically, but the program cannot;

④ A process consists of three parts: Process Control Block, program segment, and data segment. ⑤ A process has the function of creating other processes, but the program does not.

⑥ When a program runs on several datasets simultaneously, it will belong to several different processes, that is, the same program can correspond to multiple processes.

7. In traditional operating systems, programs cannot run independently. as the basic unit for resource allocation and independent operation, they are all processes.

A worker can usually contain several threads in a process, which can take advantage of the resources of the process. In the operating system that introduces the thread, the process is usually used as the basic unit for resource allocation, taking a thread as the basic unit of independent operation and independent scheduling, because the thread is smaller than the process and basically does not have system resources, the overhead of scheduling will be much lower, it can improve the degree of concurrent execution among multiple programs in the system more efficiently.

2. A process is a running activity that can be executed concurrently in a data set of programs with independent functions. Its basic features include dynamic features, concurrency features, independence, and mutual restraint.

3. Three basic scheduling statuses are available for a process.

① A ready-state process has obtained all the resources except the processor, waiting for the allocation of processor resources; it can be executed as long as the processor process is allocated. Ready processes can divide queues by multiple priorities. For example, when a process enters the ready state due to time slice usage, it is discharged into the low-priority queue. When the process enters the ready state after the I/O operation is completed, it is discharged into the high-priority queue.

② Processes in the execution state occupy processor resources. The number of processes in this state is less than or equal to the number of processors. When no other process can be executed (for example, all processes are blocked), the idle process of the system is automatically executed.

③ The waiting state cannot be executed until the process waits for certain conditions (such as I/O operations or process synchronization. Even if the processor is assigned to the process before the event occurs, it cannot run.

4. The introduction of processes greatly improves the resource utilization and system throughput, while the introduction of threads aims to reduce the system overhead of program concurrency. A process is the unit of resource allocation, while a thread is the unit of system scheduling.

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.