Skip to content
Sahithyan's S3
1
Sahithyan's S3 — Operating Systems

Synchronization

A way to control how concurrently-running threads and processes access shared resources. To maintain correctness, the OS must enforce an ordered way for processes to execute code that accesses shared data.

A situation where the correctness of a program is unpredictable as it depends on the relative timing or interleaving of threads or processes.

Part of code that accesses or modifies shared resources.

Aka. pre-protocol. Part of the code executed before the critical section. Necessary synchronization steps are done by the thread to request permission to enter the critical section.

Aka. post-protocol. Part of the code executed immediately after the critical section. The thread releases locks and signals other threads waiting to enter their critical section.

All other code than critical, entry and exit sections.

The number of threads waiting to enter their critical sections at the same time. Lower is better.

Can be reduced by:

  • minimizing shared resources
  • using finer-grained locks
  • using algorithms that allow more concurrent access

No contention means, no threads are waiting to enter their critical section.