Differences between processes, programs, and threads

Source: Internet
Author: User

Differences between processes, programs, and threads
Procedure 1. Difference ① 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; ④ the process is composed of three parts: Process Control Block, program segment, and data segment; ⑤ the 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. There are three basic scheduling states for a process. ① The ready state process has obtained the resources required except the processor, waiting for the allocation of the processor resources. As long as the processor process is allocated, the process can be executed. 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.
Compare programs, processes, and threads

Process and program differences and contact lists are as follows:
1) a program is an ordered set of commands. It does not have any running meaning.
A static object. The process is different. It is the execution of a program on a certain dataset.
A process is a dynamic entity that has its own lifecycle. It is created because
Scheduling and running, waiting for resources or events, and being in the waiting status, because the task is completed
Undo. It reflects all the dynamic processes of a program running on a certain dataset.
2) processes and programs do not correspond one by one. When a program is executed on different datasets
For different processes, you can use the process control block to uniquely identify each process. And this
This is exactly what the program cannot do. Because the program has no direct connection with the data
For programs that execute different data, the set of their commands is still the same, so they cannot
The only landmark identifies the programs that run on different datasets. Generally, a process
There must be a corresponding program, and there is only one. But a program may not
The corresponding process (because it is not executed), there may also be multiple processes corresponding to it (
Rows on several different datasets ).
3) The process is also concurrent and interactive, which is different from the closed process.
Bytes ----------------------------------------------------------------------------------------------

Processes and threads are the basic units for running programs that the operating system understands. The system uses this basic unit to realize the system's concurrency for applications. The difference between a process and a thread is:

In short, a program has at least one process, and a process has at least one thread.
The thread division scale is smaller than the process, making the multi-thread program highly concurrent.
In addition, the process has independent memory units during execution, and multiple threads share the memory, which greatly improves the program running efficiency.
The execution process of a thread is different from that of a process. Each Independent thread has a program running entry, sequence execution sequence, and program exit. But the thread cannot be executed independently. It must exist in the application and the application provides multiple thread execution control.
Logically, multithreading means that multiple execution parts in an application can be executed simultaneously. However, the operating system does not view multiple threads as multiple independent applications to implement process scheduling, management, and resource allocation. This is an important difference between processes and threads.

A process is a running activity of a program with certain independent functions. A process is an independent unit for the system to allocate and schedule resources.
A thread is an entity of a process. It is the basic unit for CPU scheduling and scheduling. It is smaller than a process and can run independently. the thread itself basically does not have system resources, and only has a few resources (such as program counters, a set of registers and stacks) that are essential for running ), however, it can share all resources of a process with other threads of the same process.
One thread can create and cancel another thread, and multiple threads in the same process can be concurrently executed.

Bytes ----------------------------------------------------------------------------------------------

Differences between processes and threads

Statement 1: A process is a running activity of a program with certain independent functions. A process is an independent unit for the system to allocate and schedule resources.

A thread is an entity of a process. It is the basic unit for CPU scheduling and scheduling. It is smaller than a process and can run independently. the thread itself basically does not have system resources, and only has a few resources (such as program counters, a set of registers and stacks) that are essential for running ), however, it can share all resources of a process with other threads of the same process.

One thread can create and withdraw another thread. multiple threads in the same process can be concurrently executed.

Statement 2: both processes and threads are the basic units for running programs that the operating system understands. The system uses this basic unit to implement the system's concurrency for applications. The difference between a process and a thread is... the remaining full text>

Compare programs, processes, and threads

Process and program differences and contact lists are as follows:
1) a program is an ordered set of commands. It does not have any running meaning.
A static object. The process is different. It is the execution of a program on a certain dataset.
A process is a dynamic entity that has its own lifecycle. It is created because
Scheduling and running, waiting for resources or events, and being in the waiting status, because the task is completed
Undo. It reflects all the dynamic processes of a program running on a certain dataset.
2) processes and programs do not correspond one by one. When a program is executed on different datasets
For different processes, you can use the process control block to uniquely identify each process. And this
This is exactly what the program cannot do. Because the program has no direct connection with the data
For programs that execute different data, the set of their commands is still the same, so they cannot
The only landmark identifies the programs that run on different datasets. Generally, a process
There must be a corresponding program, and there is only one. But a program may not
The corresponding process (because it is not executed), there may also be multiple processes corresponding to it (
Rows on several different datasets ).
3) The process is also concurrent and interactive, which is different from the closed process.
Bytes ----------------------------------------------------------------------------------------------

Processes and threads are the basic units for running programs that the operating system understands. The system uses this basic unit to realize the system's concurrency for applications. The difference between a process and a thread is:

In short, a program has at least one process, and a process has at least one thread.
The thread division scale is smaller than the process, making the multi-thread program highly concurrent.
In addition, the process has independent memory units during execution, and multiple threads share the memory, which greatly improves the program running efficiency.
The execution process of a thread is different from that of a process. Each Independent thread has a program running entry, sequence execution sequence, and program exit. But the thread cannot be executed independently. It must exist in the application and the application provides multiple thread execution control.
Logically, multithreading means that multiple execution parts in an application can be executed simultaneously. However, the operating system does not view multiple threads as multiple independent applications to implement process scheduling, management, and resource allocation. This is an important difference between processes and threads.

A process is a running activity of a program with certain independent functions. A process is an independent unit for the system to allocate and schedule resources.
A thread is an entity of a process. It is the basic unit for CPU scheduling and scheduling. It is smaller than a process and can run independently. the thread itself basically does not have system resources, and only has a few resources (such as program counters, a set of registers and stacks) that are essential for running ), however, it can share all resources of a process with other threads of the same process.
One thread can create and cancel another thread, and multiple threads in the same process can be concurrently executed.

Bytes ----------------------------------------------------------------------------------------------

Differences between processes and threads

Statement 1: A process is a running activity of a program with certain independent functions. A process is an independent unit for the system to allocate and schedule resources.

A thread is an entity of a process. It is the basic unit for CPU scheduling and scheduling. It is smaller than a process and can run independently. the thread itself basically does not have system resources, and only has a few resources (such as program counters, a set of registers and stacks) that are essential for running ), however, it can share all resources of a process with other threads of the same process.

One thread can create and withdraw another thread. multiple threads in the same process can be concurrently executed.

Statement 2: both processes and threads are the basic units for running programs that the operating system understands. The system uses this basic unit to implement the system's concurrency for applications. The difference between a process and a thread is... the remaining full text>

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.