Process, line Cheng CPU relationship Brief

Source: Internet
Author: User

This paper briefly describes the relationship between the process and the thread, in order to facilitate understanding, this article will briefly describe how the CPU works.

Process is a computer program on a set of data on a running activity, the system is the basic unit of resource allocation and scheduling, is the basis of the operating system structure. Or a process is a program with a certain set of independent functions on a data collection of a running activity, the process is the system for 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.

Relationship of process and thread:

(1) A thread can belong to only one process, while a process may have multiple threads, but at least one thread.

(2) A resource is allocated to a process, and all the threads of the same process share all the resources of that process.

(3) The processor is assigned to a thread, that is, a thread that is actually running on the processing machine.

(4) Threads need to be synchronized during execution. Synchronization is achieved between threads of different processes using the means of message communication.

Open your task Manager to see a column of processes. Such as:




The tree diagram of the program, thread, and process is as follows:


The operating system is designed so that it boils down to three points:

(1) Multi-process mode, allowing multiple tasks to run simultaneously;

(2) in multi-threaded form, allowing individual tasks to be divided into different parts of the operation;

(3) Provide a coordination mechanism to prevent conflicts between processes and threads, and to allow the sharing of resources between processes and threads on the other.

For example, when we play the fighting game program, the Player 1 punch, the Player 2 block, the two action is at the same time, so it involves multi-threading, so the game process to have at least two threads, respectively, the move and block. For example, we chat with QQ, while opening QQ music, at this time we feel that QQ chatting and QQ music is at the same time, but the CPU can only handle one thing at the same moment.

I think everyone should have seen or liked to read a comic book when you are young, and when you flip through that book quickly, the characters in the book seem to be moving, the so-called frame-by-picture animation, the CPU's handling of the event is similar to the principle.

When you run QQ chat and QQ Music, the work of the CPU is constantly switching process, if the switch 6 times per second, you will feel the card, if you switch fast enough, you will feel is running QQ music and QQ chat.

Conclusion:

(1) Threads are part of a process

(2) The CPU is scheduling the thread

(3) The system allocates resources for the process and does not assign resources to threads

Original address: http://blog.csdn.net/u013322876/article/details/50595886

Process, line Cheng CPU relationship Brief

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.