Operating system--the difference between a process and a thread

Source: Internet
Author: User

http://blog.csdn.net/andy6355/article/details/2506171

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 one run activity on a data set , a process is an independent unit of system resource allocation and scheduling .

a thread is an entity of a process 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 ), However, it can share all of the resources owned by the process with other threads that belong to one process .

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

The main difference between processes and threads is that they are different ways to manage operating system resources. The process has a separate address space, and after a process crashes, it does not affect other processes in protected mode, and the thread is just a different execution path in a process. Thread has its own stack and local variables, but there is no separate address space between the threads, a thread dead is equal to the entire process dead, so the multi-process program is more robust than multithreaded programs, but in the process of switching, the cost of large resources, efficiency is worse. But for some concurrent operations that require simultaneous and shared variables, only threads can be used, and processes cannot be used.

Operating system--differences between processes and threads (RPM)

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.