-
Notifications
You must be signed in to change notification settings - Fork 2
/
Copy pathtls.tex
23 lines (18 loc) · 1004 Bytes
/
tls.tex
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
\abschnitt{multi-threading environment}\label{xthread}
Any thread in a program may be shared by multiple fibers.
A newly-instantiated fiber is not yet associated with any thread. However,
once a fiber has been resumed the first time by some thread, it must
thereafter be resumed only by that same thread.
There could potentially be Undefined Behaviour if:
\begin{itemize}
\item a function running on a fiber references \cpp{thread\_local} variables
\item the compiler/runtime implementation caches a pointer
to \cpp{thread\_local} storage in that function's stack frame
\item that fiber is suspended, and
\item the suspended fiber is resumed on a different thread.
\end{itemize}
The cached TLS pointer is now pointing to storage belonging to some other
thread. If the original thread terminates before the new thread, the cached
TLS pointer is now dangling.
For this reason, it is forbidden to resume a fiber on any thread other than
the one on which it was first resumed.