Home  >  Article  >  What is the role of threads

What is the role of threads

anonymity
anonymityOriginal
2019-05-07 13:32:5016950browse

What is the role of threads

Thread (thread) is a single sequence of control flow in a "process". Also called lightweight processes. Computer science term referring to the scheduling unit of a running program.

Thread, sometimes called a lightweight process (LWP), is the smallest unit of program execution flow. A standard thread consists of a thread ID, a current instruction pointer (PC), a register set and a stack. In addition, a thread is an entity in the process and is the basic unit that is independently scheduled and dispatched by the system. The thread itself does not own system resources, only some resources that are essential for operation, but it can communicate with other threads that belong to the same process. Share all resources owned by the process. A thread can create and destroy another thread, and multiple threads in the same process can execute concurrently. Due to the mutual constraints between threads, threads show discontinuity in their operation. Threads also have three basic states: ready, blocked and running. Every program has at least one thread. If a program has only one thread, it is the program itself.

To put it simply, each of your CPU cores is a thread. AMD's CPU has as many threads as there are cores.
For example, AMD Athlon II process!
For example, the I5 3450 has 4 cores and 4 threads. The high-end I7 supports hyper-threading technology. The i7 3970X has 6 cores and 12 processes.

Function:

Simply speaking, it is the function of the CPU. , More threads can increase the speed of parallel execution of the program, but the more the better, each thread takes up memory, and multi-threading means that more memory resources are occupied. Secondly, from a micro perspective , a CPU does not execute two threads at the same time, it executes them in turn, so there are too many threads, and the CPU must constantly switch executions between threads. Switching between threads unintentionally consumes a lot of time, so the CPU is effectively utilized The rate actually dropped

The above is the detailed content of What is the role of threads. For more information, please follow other related articles on the PHP Chinese website!

Statement:
The content of this article is voluntarily contributed by netizens, and the copyright belongs to the original author. This site does not assume corresponding legal responsibility. If you find any content suspected of plagiarism or infringement, please contact admin@php.cn
Previous article:What does swap mean?Next article:What does swap mean?