Thread Process coprocessor

Source: Internet
Author: User

One, what is a thread?

  a thread is the smallest unit (the smallest unit of program execution flow) that the operating system can perform operations on. It is included in the process and is the actual operating unit of the process. a thread refers to a single sequential control flow in which multiple threads can be concurrently in a process, and each thread performs different tasks in parallel.

A standard thread consists of a thread ID, a current instruction pointer (PC), a collection of registers, and a stack. In addition, the thread is an entity in the process and is the basic unit of dispatch and dispatch by the system, the thread itself does not own the system resources, only has a bit of resources that are essential in the operation, but it can share all the resources owned by the process with other threads belonging to one process. One thread can create and revoke another thread, which can be executed concurrently between multiple threads in the same process. Because of the mutual restriction between threads, the thread is running intermittently. Threads are also ready to block and run three basic states. A ready state is a thread that has all of the conditions running, is logically capable of running, is waiting on a processing machine, and a running state is a thread-owning processor that is running; a blocking state is a thread waiting for an event, such as a semaphore, to be logically unenforceable. Each program has at least one thread, such as a program with only one thread, which is the program itself.

A thread is a single sequential control flow in a program. A relatively independent, scheduled execution unit within the process. is the System independent dispatch and dispatch CPU's basic unit refers to the running program's dispatch unit. Running multiple threads at the same time in a single program accomplishes different tasks, called multithreading.

Second, what is the process?

Process is a computer program on a data set on a running activity, the system is the basic unit of resource allocation and scheduling, is the basis of the operating system structure. In the early process design-oriented computer organization, the process is the basic executing entity of the program, in the modern thread-oriented computer architecture, the process is the container of the thread. A program is a description of the instruction, the data and its organization, and the process is the entity of the program. It contains the calls to various resources, the management of memory, the invocation of the network interface and so on.

Third, what is the association process?

Co-process, also known as micro-threading, fiber. English name Coroutine.

The process looks like a subroutine, but it is not the same as the subroutine, which, in the course of execution, can execute another subroutine after interrupting the current subroutine, and then return to the subroutine before execution, but the relevant information is the previous one.

Description: The co-process is suitable for I/O intensive tasks, processing CPU-intensive tasks is not its advantage, if you want to improve CPU utilization can consider "multi-process + coprocessor" mode.

Iv. the difference between threads and processes

1, thread shared memory space, process memory is independent

2, the same process between the threads can communicate directly, two processes want to communicate, must through an intermediary agent to achieve.

3. Creating a new thread is simple, and creating a new process requires a clone of its parent process.

4. One thread can control and manipulate other processes in the same process, but the process can only manipulate child processes.

5, change the main thread may affect other threads, change the parent process, does not affect the child process.

V. The difference between the process and the thread

1, the co-process and the thread has a very high execution efficiency. Because the subroutine switch is not a thread switch, it is controlled by the program itself. Therefore, there is no thread switching overhead, and multithreading ratio, the more the number of threads, the performance advantage of the association is obvious.

2, the association process does not require a multi-threaded lock mechanism, because there is only one thread, there is no simultaneous write variable conflict, in the process of controlling the shared resources are not locked, only need to judge the state is good.

3, because the process is a thread execution, then how to use multi-core CPU it? The simplest method is multi-process + co-progression, which takes full advantage of multicore, and maximizes the high-efficiency of the co-processes, which can achieve very good performance.

Thread Process coprocessor

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.