Files
2025-10-25 03:02:53 +03:00

68 lines
2.7 KiB
Markdown
Raw Permalink Blame History

This file contains invisible Unicode characters

This file contains invisible Unicode characters that are indistinguishable to humans but may be processed differently by a computer. If you think that this is intentional, you can safely ignore this warning. Use the Escape button to reveal them.

[intro.multithread.general]
# 6 Basics [[basic]](./#basic)
## 6.10 Program execution [[basic.exec]](basic.exec#intro.multithread.general)
### 6.10.2 Multi-threaded executions and data races [[intro.multithread]](intro.multithread#general)
#### 6.10.2.1 General [intro.multithread.general]
[1](#1)
[#](http://github.com/Eelis/draft/tree/9adde4bc1c62ec234483e63ea3b70a59724c745a/source/basic.tex#L6564)
A [*thread of execution*](#def:thread_of_execution "6.10.2.1General[intro.multithread.general]") (also known as a [*thread*](#def:thread "6.10.2.1General[intro.multithread.general]")) is a single flow of
control within a program, including the initial invocation of a specific
top-level function, and recursively including every function invocation
subsequently executed by the thread[.](#1.sentence-1)
[*Note [1](#note-1)*:
When one thread creates another,
the initial call to the top-level function of the new thread is executed by the
new thread, not by the creating thread[.](#1.sentence-2)
— *end note*]
Every thread in a program can
potentially use every object and function in a program[.](#1.sentence-3)[37](#footnote-37 "An object with automatic or thread storage duration ([basic.stc]) is associated with one specific thread, and can be accessed by a different thread only indirectly through a pointer or reference ([basic.compound]).")
Under a hosted
implementation, a C++ program can have more than one thread running
concurrently[.](#1.sentence-4)
The execution of each thread proceeds as defined by the remainder
of this document[.](#1.sentence-5)
The execution of the entire program consists of an execution
of all of its threads[.](#1.sentence-6)
[*Note [2](#note-2)*:
Usually the execution can be viewed as an
interleaving of all its threads[.](#1.sentence-7)
However, some kinds of atomic operations, for
example, allow executions inconsistent with a simple interleaving, as described
below[.](#1.sentence-8)
— *end note*]
Under a freestanding implementation, it is implementation-defined whether a program can
have more than one thread of execution[.](#1.sentence-9)
[2](#2)
[#](http://github.com/Eelis/draft/tree/9adde4bc1c62ec234483e63ea3b70a59724c745a/source/basic.tex#L6600)
For a signal handler that is not executed as a result of a call to thestd::raise function, it is unspecified which thread of execution
contains the signal handler invocation[.](#2.sentence-1)
[37)](#footnote-37)[37)](#footnoteref-37)
An object
with automatic or thread storage duration ([[basic.stc]](basic.stc "6.8.6Storage duration")) is associated with
one specific thread, and can be accessed by a different thread only indirectly
through a pointer or reference ([[basic.compound]](basic.compound "6.9.4Compound types"))[.](#footnote-37.sentence-1)