Synchronization for short periods, Synchronization for short periods -22 – Intel ARCHITECTURE IA-32 User Manual

Page 368

Advertising
background image

IA-32 Intel® Architecture Optimization

7-22

Synchronization for Short Periods

The frequency and duration that a thread needs to synchronize with
other threads depends application characteristics. When a
synchronization loop needs very fast response, applications may use a
spin-wait loop.

A spin-wait loop is typically used when one thread needs to wait a short
amount of time for another thread to reach a point of synchronization. A
spin-wait loop consists of a loop that compares a synchronization
variable with some pre-defined value [see Example 7-4(a)].

On a modern microprocessor with a superscalar speculative execution
engine, a loop like this results in the issue of multiple simultaneous read
requests from the spinning thread. These requests usually execute
out-of-order with each read request being allocated a buffer resource.
On detection of a write by a worker thread to a load that is in progress,

Miscellaneous

Some objects
provide intra-process
synchronization and
some are for
inter-process
communication

Must lock accesses to
synchronization
variable if several
threads may write to it
simultaneously.
Otherwise can write
without locks.

Same as light weight.
Also can be used only
on systems that
support
MONITOR/MWAIT.

Recommended
use conditions

1. # of active threads

> # of cores.

2. Waiting thousands

of cycles for a
signal.

3. Synchronization

among processes

1.The number of active

threads is less or
equal to the number
of cores.

2. Infrequent

contention.

3. Need inter process

synchronization

1. Same as light

weight objects.

2. MONITOR/MWAIT

available

Table 7-1

Properties of Synchronization Objects (Contd.)

Characteristics

Operating System

Synchronization

Objects

Light Weight User Syn-

chronization

Synchronization

Object based on MON-

ITOR/MWAIT

Advertising