search
HomeCommon ProblemWhat is the part that threads in the same process do not share?

What is the part that threads in the same process do not share?

The part that threads in the same process do not share is the thread's stack.

The environment shared by threads includes: process code segments, public data of the process (using these shared data, threads can easily communicate with each other), file descriptors opened by the process, and signals The processor, the current directory of the process, and the process user ID and process group ID.

While processes have many commonalities, they also have their own personality. With these personalities, threads can achieve concurrency. These characteristics include:

1. Thread ID

Each thread has its own thread ID, which is unique in this process. Processes use this to identify threads.

2. Register group value

Since threads run concurrently, each thread has its own different running clues. When switching from one thread to another, , the state of the original thread's register set must be saved so that the thread can be restored when it is switched again in the future.

3. Thread stack

#The stack is necessary to ensure that the thread runs independently. Thread functions can call functions, and the called functions can be nested layer by layer, so the thread must have its own function stack so that the function call can be executed normally without being affected by other threads.

4. Error return code

Since there are many threads running in the same process at the same time, it is possible that a certain thread sets the errno value after making a system call, and in that process The thread has not yet processed this error, and another thread is put into operation by the scheduler at this time, so the error value may be modified. Therefore, different threads should have their own error return code variables.

5. Thread's signal masking code

Since each thread is interested in different signals, the thread's signal masking code should be managed by the thread itself. But all threads share the same signal handler.

6. Thread priority

Since threads need to be scheduled like processes, there must be parameters available for scheduling. This parameter is the priority of the thread.

The above is the detailed content of What is the part that threads in the same process do not share?. 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

Hot AI Tools

Undresser.AI Undress

Undresser.AI Undress

AI-powered app for creating realistic nude photos

AI Clothes Remover

AI Clothes Remover

Online AI tool for removing clothes from photos.

Undress AI Tool

Undress AI Tool

Undress images for free

Clothoff.io

Clothoff.io

AI clothes remover

Video Face Swap

Video Face Swap

Swap faces in any video effortlessly with our completely free AI face swap tool!

Hot Tools

SublimeText3 Linux new version

SublimeText3 Linux new version

SublimeText3 Linux latest version

Dreamweaver Mac version

Dreamweaver Mac version

Visual web development tools

ZendStudio 13.5.1 Mac

ZendStudio 13.5.1 Mac

Powerful PHP integrated development environment

SecLists

SecLists

SecLists is the ultimate security tester's companion. It is a collection of various types of lists that are frequently used during security assessments, all in one place. SecLists helps make security testing more efficient and productive by conveniently providing all the lists a security tester might need. List types include usernames, passwords, URLs, fuzzing payloads, sensitive data patterns, web shells, and more. The tester can simply pull this repository onto a new test machine and he will have access to every type of list he needs.

SublimeText3 Mac version

SublimeText3 Mac version

God-level code editing software (SublimeText3)