Compare-and-Swap

Turkish equivalent: Karşılaştır ve değiştirDomain: Concurrency

An atomic read-modify-write primitive that updates a memory location only when its current value matches an expected value.

Concurrency Context

Compare-and-swap (CAS) is a core read-modify-write primitive in lock-free stacks, queues, counters, and state machines. A failed CAS normally means the caller must observe the new value and retry using an updated assumption.

Correctness and Progress Boundary

A retry loop around CAS can become expensive under contention, and CAS-based designs can be exposed to the ABA Problem. Lock-free progress also does not imply that every individual thread is protected from starvation.

Related technical publications

Publications whose title or summary directly references this concept.

Computer Networks: Protocols, Routing, and Security

Layered technical notes covering computer networks from physical transmission and Ethernet through IPv4/IPv6, advanced routing, multicast, QoS, wireless, security, data centers, network programming, observability, and automation.

Finite-State Turkish Syllabification Algorithm

Turkish syllabification can be implemented in linear time by tracking vowel and consonant transitions with a small state machine; the difficult cases arise in compounds and non-linguistic input.

The Real Cost of Lock-Free Queues

A lock-free queue can still lose on tail latency when CAS contention, cache-line ownership, allocation and backpressure are ignored.