Table of Contents Previous Next
Logo
Threads and Concurrency with C++ : 31.10 Efficiency Considerations
Copyright © 2003-2008 ZeroC, Inc.

31.10 Efficiency Considerations

The mutual exclusion mechanisms provided by Ice differ in their size and speed. Table 31.1 shows the relative sizes for Windows and Linux (both on Intel 32‑bit architectures).

1
Note that, under Windows, the size reported by sizeof is inaccurate because synchronization primitives allocate OS resources that consume memory but are not reported by sizeof.

In terms of speed, RecMutex, Monitor<Mutex>, and Monitor<RecMutex> perform within a few percentage points of Mutex for a critical region that is not under contention. However, locking and unlocking a RWRecMutex is 3–40 times slower than locking and unlocking a Mutex, depending on the operating system, compiler, and CPU architecture. If lock performance is important to your application, we suggest you take your own measurements to assess the relative performance of the different synchronization primitives.

Table of Contents Previous Next
Logo