Home > Common Problem > body text

The basic unit for allocating CPU

(*-*)浩
Release: 2019-07-23 15:56:41
Original
14305 people have browsed it

The basic unit of allocating CPU time in Windows is the thread. A thread is the smallest unit that the operating system can perform operation scheduling. It is included in the process and is the actual operating unit in the process.

The basic unit for allocating CPU

A thread refers to a single sequential control flow in a process. Multiple threads can run concurrently in a process. Each thread Execute different tasks in parallel. (Recommended learning: PHP video tutorial)

is also called lightweight processes in Unix System V and SunOS, but lightweight processes refer more to kernel threads. thread), and the user thread (user thread) is called a thread.

Threads are the basic unit of independent scheduling and dispatch.

Threads can be kernel threads scheduled by the operating system kernel, such as Win32 threads; user threads scheduled by the user process itself, such as POSIX Thread on the Linux platform; or threads between the kernel and user processes, such as Windows 7 threads. Perform hybrid scheduling.

Threads are entities in a process. A process can have multiple threads, and a thread must have a parent process. The thread does not own system resources, only some data structures necessary for operation; it shares all resources owned by the process with other threads of the parent process. Threads can create and destroy threads to achieve concurrent execution of programs.

Generally, threads have three basic states: ready, blocked and running.

In a multi-CPU system, different threads can run on different CPUs at the same time, even when they belong to the same process. Most operating systems that support multi-processors provide programming interfaces that allow processes to control the affinity between their own threads and each processor.

Sometimes, threads are also called lightweight processes. Just like processes, threads are independent, concurrent execution paths in the program. Each thread has its own stack, its own program counter, and its own local variables. However, threads within a process are less isolated from each other than separate processes.

They share memory, file handles, and other states that each process should have.

A process can support multiple threads, which appear to execute simultaneously but are not synchronized with each other. Multiple threads in a process share the same memory address space, which means they can access the same variables and objects, and they allocate objects from the same heap.

Although this makes it easier to share information between threads, you must be careful to ensure that they do not interfere with other threads in the same process.

For more PHP-related technical articles, please visit the PHP Graphic Tutorial column to learn!

The above is the detailed content of The basic unit for allocating CPU. For more information, please follow other related articles on the PHP Chinese website!

Related labels:
cpu
source:php.cn
Statement of this Website
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
Popular Tutorials
More>
Latest Downloads
More>
Web Effects
Website Source Code
Website Materials
Front End Template