Tagged articles
9 articles
Page 1 of 1
Liangxu Linux
Liangxu Linux
Nov 21, 2024 · Fundamentals

When to Use Spin Locks and How They Work in Multithreaded Code

This article explains the concept of spin locks, compares them with mutexes, shows how to use the pthread API and C++ atomic_flag to implement them, outlines suitable scenarios, highlights CPU‑usage pitfalls, and provides practical code examples.

C++Synchronizationconcurrency
0 likes · 10 min read
When to Use Spin Locks and How They Work in Multithreaded Code
IT Services Circle
IT Services Circle
Oct 21, 2022 · Fundamentals

Understanding Thread Blocking and Scheduling in Operating Systems

The article explains what thread blocking means in operating systems, how the OS moves blocked threads to wait queues and schedules other threads, discusses spin locks, and reflects on common misconceptions and community debates about callbacks versus polling.

AsynchronousSchedulingspin lock
0 likes · 5 min read
Understanding Thread Blocking and Scheduling in Operating Systems
Code Ape Tech Column
Code Ape Tech Column
May 17, 2022 · Fundamentals

Understanding Compare‑And‑Swap (CAS), Its Mechanisms, and Common Pitfalls

This article explains the fundamentals of the compare‑and‑swap (CAS) atomic primitive, how CPUs guarantee its atomicity through bus and cache locking, illustrates a Java spin‑lock implementation using CAS, and discusses typical issues such as single‑variable limitation, long spin times, and the ABA problem with mitigation strategies.

ABA problemCASJava
0 likes · 9 min read
Understanding Compare‑And‑Swap (CAS), Its Mechanisms, and Common Pitfalls