Programs, processes, threads

Source: Internet
Author: User

program process thread Learning notes

Defined:

A program is just an ordered set of instructions.

The second process is a program with a certain independent function on a data set on a running activity, is the system of resource allocation and scheduling of an independent unit;

A thread is an entity of a process that is the basic unit of CPU dispatch and dispatch, which is a smaller unit that can run independently than a process. The thread itself basically does not own the system resources, only has a point in the operation of the necessary resources (such as program counters, a set of registers and stacks), one can create and revoke another thread ;

  a process and thread differences and linkages

  (1) partition scale : The thread is smaller, so multithreading program concurrency is higher ;

  (2) resource allocation & Processor scheduling: A process is the basic unit of resource allocation, and threads are the basic unit of processor scheduling.   

(3) address space: The process has a separate address space, the thread does not have a separate address space, multiple threads within the same process share its resources ;

  (4) execution: Each thread has a program to run the portal, sequential execution sequence and the exit of the program, but the thread cannot be executed separately, must compose a process, a process has at least one main thread. In short, a program has at least one process, and a process has at least one thread.

Two processes and procedural differences and linkages

(1) A program is just a set of ordered sets of instructions, which itself does not have any meaning of running, it is just a static entity. And the process is different, it is the execution of a program on a data set. A process is a dynamic entity that has its own life cycle . Reflects the entire dynamic process of a program running on a certain set of data.

(2) Processes and procedures are not one by one corresponding, a program execution on different datasets becomes a different process, you can use the process control block to uniquely identify each process. This is what the program is unable to do, because the program does not have a direct connection with the data, even to the execution of different data programs, their set of instructions are still the same, so it is not possible to uniquely identify these programs running on different datasets. In general, a process must have a corresponding program, and only one. While a program may not have a corresponding process (because it is not executed), there may be multiple processes corresponding to it (running on several different datasets).

(3) The process also has concurrency and communication, which is also different from the closure of the program.

Process and procedural differences and linkages are manifested in the following areas:

1) The program is just a set of ordered sets of instructions, which itself does not have any meaning of running, it is just a static entity. And the process is different, it is the execution of a program on a data set.

A process is a dynamic entity that has its own life cycle. It is created because it is scheduled to run, is waiting for a resource or event, and is undone due to completion of the task. Reflects the entire dynamic process of a program running on a certain set of data.

2) Processes and procedures are not one by one corresponding, a program execution on different datasets becomes a different process, you can use the process control block to uniquely identify each process. This is what the program is unable to do, because the program does not have a direct connection with the data, even to the execution of different data programs, their set of instructions are still the same, so it is not possible to uniquely identify these programs running on different datasets. In general, a process must have a corresponding program, and only one. While a program may not have a corresponding process (because it is not executed), there may be multiple processes corresponding to it (running on several different datasets).

3) The process also has concurrency and communication, which is also different from the closure of the program. Processes and threads are the basic units that the operating system realizes, and the system uses this basic unit to realize the concurrency of the system to the application. 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's dividing scale is smaller than the process, which makes the multi-thread procedure high concurrency.

In addition, the process has a separate memory unit during execution, and multiple threads share memory, which greatly improves the efficiency of the program operation.

Threads are still different from the process during execution. Each separate thread has a program run entry, sequence of sequence execution, and exit of the program. However , threads cannot be executed independently, and must be dependent on the application, which provides multiple threads of execution control.

From a logical point of view, the meaning of multithreading is that in an application, multiple execution parts can be executed concurrently. However, the operating system does not consider multiple threads as separate applications to implement scheduling and management of processes and resource allocation. This is the important difference between processes and threads.

A process is a program with a certain independent function about a single run activity on a data set, a process that is an independent unit of the system's resource allocation and scheduling.

  a thread is an entity of a process , is a CPU the basic unit of Dispatch and dispatch , which is a smaller unit that can run independently than a process . threads themselves do not have system resources at all , have only a few resources that are essential in the run ( such as program counters , A set of registers and stacks ), but it can share all the resources owned by the process with other threads of the same process .

One thread can create and revoke another thread, and can execute concurrently between multiple threads in the same process.

Programs, processes, threads

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.