全部书籍

专业

应用 关于 Coach 登录 开始阅读

书籍暂未推出简体中文版——当前显示英文版。

Computer Science · 术语表

什么是 Lock-free, wait-free, ABA problem?

又称: lock-free · wait-free · ABA problem

Definition 13.11 University Computer Science — Year 3 · 第 13 章 — Concurrency: Deadlock, Monitors and Lock-Free Structures

An implementation of a shared object is lock-free if, whenever threads are running its operations, some operation completes after a finite number of steps of the system, whatever the scheduling. It is wait-free if every operation completes in a finite number of its own thread’s steps. The ABA problem arises when a thread reads a value A, then between its read and its CAS other threads change A to B and back to A: the CAS succeeds when it should not.

The ABA problem in three snapshots. Thread 1’s CAS compares only the head, A, and swings it to the successor it read in snapshot 1. B is now on the stack and in thread 2’s hands at once.
The ABA problem in three snapshots. Thread 1’s CAS compares only the head, A, and swings it to the successor it read in snapshot 1. B is now on the stack and in thread 2’s hands at once.
在原文中阅读 →