Critical Sections Overview

This document is an overview of critical sections.

Purpose

Synchronises exclusive access to shared resources within a single process.

Description

Critical sections are typically used to serialize access to a section of re-entrant code that cannot be executed concurrently by more than one thread within a process. A critical section object only allows one thread into a controlled section, forcing other threads which attempt to gain access to that critical section to wait until the first thread has exited from that section.

A critical section cannot be used to control access to a resource shared by threads across different processes. For that, use a mutex.

Critical sections are Kernel objects and, as such, are managed by the Kernel, and accessed by user programs through handles. They are implemented using a semaphore.

The critical section handle is provided by RCriticalSection .