- Mastering C++ Multithreading
- Maya Posch
- 155字
- 2021-07-15 17:34:01
Hardware
The simplest hardware-based implementation on a uniprocessor (single processor core), non-SMT system is to disable interrupts, and thus, prevent the task from being changed. More commonly, a so-called busy-wait principle is employed. This is the basic principle behind a mutex--due to how the processor fetches data, only one task can obtain and read/write an atomic value in the shared memory, meaning, a variable sized the same (or smaller) as the CPU's registers. This is further detailed in Chapter 8, Atomic Operations - Working with the Hardware.
When our code tries to lock a mutex, what this does is read the value of such an atomic section of memory, and try to set it to its locked value. Since this is a single operation, only one task can change the value at any given time. Other tasks will have to wait until they can gain access in this busy-wait cycle, as shown in this diagram:

- Modular Programming with Python
- HBase從入門到實戰
- Mastering Python Scripting for System Administrators
- HTML5游戲開發案例教程
- C語言程序設計立體化案例教程
- Building a Quadcopter with Arduino
- Learning Three.js:The JavaScript 3D Library for WebGL
- Mastering JavaScript High Performance
- Android程序設計基礎
- 軟件品質之完美管理:實戰經典
- Arduino計算機視覺編程
- Raspberry Pi Robotic Blueprints
- 零代碼實戰:企業級應用搭建與案例詳解
- Raspberry Pi開發實戰
- Python量子計算實踐:基于Qiskit和IBM Quantum Experience平臺