Threads, Processes, and Shared Address Spaces

Identify which execution state belongs to a thread and which resources are normally shared within its process.

Source
Anbloq
Language
English
Created
Updated
Chapters
2
Reading time
1 min
In this article2 chapters
  1. Several instruction streams can use the same mappings
  2. Sharing memory requires an ordering contract

Several instruction streams can use the same mappings

Threads of one process commonly share its address space and process-managed resources. Each thread has its own program counter, register state and stack region. Stack memory can still be addressable by other threads in the same space. Its lifetime and access discipline therefore matter when an address is shared. Separate processes can exchange data through explicit shared memory or a mediated channel.

Sharing memory requires an ordering contract

If two threads update a pool’s free-list head, they can read the same old head and lose one update unless the operation is protected by an appropriate synchronization rule. Separate thread stacks do nothing to serialize updates to that shared object. Synchronization and happens-before specifies when one thread’s writes are visible to another. Context switches describe what the scheduler changes when a thread stops running.[1]

References

  1. Remzi H. Arpaci-Dusseau and Andrea C. Arpaci-Dusseau, Operating Systems: Three Easy Pieces ↩