liveBook · Manning

Thread storage duration

As explained in Modern C, Third Edition

Thread storage duration is an object storage duration associated with a particular thread of execution.

Thread storage duration gives an object storage duration associated with a particular thread of execution. In C23, the spelling is `thread_local`; earlier C uses `_Thread_local`. section 13.2

Keep these distinctions in view:

  • Thread storage duration belongs to the storage-duration classification and is related to C’s thread API. section 13.2
  • Do not equate static storage duration with the `static` storage-class specifier: `static` concerns linkage, while storage duration describes the associated object’s lifetime. section 13.2
  • Objects with thread storage duration receive default initialization: arithmetic members become 0 and pointer members become nullptr. section 13.4

The spelling identifies the duration

A declaration using `thread_local` expresses thread storage duration in C23; the corresponding spelling before C23 is `_Thread_local`. The declaration’s storage-duration category also determines that default initialization applies. section 13.2 section 13.4

How Modern C, Third Edition covers it

How deep it goes
Defines the duration and its initialization rule but defers detailed thread-API treatment.
Examples
Uses the C23 `thread_local` spelling and the earlier `_Thread_local` spelling as concrete language constructs.
What you can do after
Evaluate/understand which initialization rule and language spelling apply to a thread-storage object.
How it connects
Connects storage duration with object lifetime, initialization, linkage, scope, and the C thread API.

Also explained in

Compare how 2 books explain thread storage duration →

Related concepts

This explainer was generated by Manning's knowledge graph from the text of Modern C, Third Edition. The section links point to the parts of the book it draws on.