Skip to Content
Understanding the Linux Kernel, 3rd Edition
book

Understanding the Linux Kernel, 3rd Edition

by Daniel P. Bovet, Marco Cesati
November 2005
Beginner content levelBeginner
942 pages
31h 13m
English
O'Reilly Media, Inc.
Content preview from Understanding the Linux Kernel, 3rd Edition

Synchronization Primitives

We now examine how kernel control paths can be interleaved while avoiding race conditions among shared data. Table 5-2 lists the synchronization techniques used by the Linux kernel. The “Scope” column indicates whether the synchronization technique applies to all CPUs in the system or to a single CPU. For instance, local interrupt disabling applies to just one CPU (other CPUs in the system are not affected); conversely, an atomic operation affects all CPUs in the system (atomic operations on several CPUs cannot interleave while accessing the same data structure).

Table 5-2. Various types of synchronization techniques used by the kernel

Technique

Description

Scope

Per-CPU variables

Duplicate a data structure among the CPUs

All CPUs

Atomic operation

Atomic read-modify-write instruction to a counter

All CPUs

Memory barrier

Avoid instruction reordering

Local CPU or All CPUs

Spin lock

Lock with busy wait

All CPUs

Semaphore

Lock with blocking wait (sleep)

All CPUs

Seqlocks

Lock based on an access counter

All CPUs

Local interrupt disabling

Forbid interrupt handling on a single CPU

Local CPU

Local softirq disabling

Forbid deferrable function handling on a single CPU

Local CPU

Read-copy-update (RCU)

Lock-free access to shared data structures through pointers

All CPUs

Let’s now briefly discuss each synchronization technique. In the later section "Synchronizing Accesses to Kernel Data Structures,” we show how these synchronization techniques can be combined to effectively protect kernel data ...

Become an O’Reilly member and get unlimited access to this title plus top books and audiobooks from O’Reilly and nearly 200 top publishers, thousands of courses curated by job role, 150+ live events each month,
and much more.
Start your free trial

You might also like

Understanding the Linux Kernel, Second Edition

Understanding the Linux Kernel, Second Edition

Daniel P. Bovet, Marco Cesati
Understanding the Linux Kernel

Understanding the Linux Kernel

Daniel P. Bovet, Marco Cesati
Linux Kernel Programming

Linux Kernel Programming

Kaiwan N. Billimoria

Publisher Resources

ISBN: 0596005652Errata Page