- 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:

- Dynamics 365 for Finance and Operations Development Cookbook(Fourth Edition)
- Computer Vision for the Web
- Mastering Adobe Captivate 2017(Fourth Edition)
- Android和PHP開發最佳實踐(第2版)
- 深入理解Java7:核心技術與最佳實踐
- Scratch 3.0少兒編程與邏輯思維訓練
- PostgreSQL 11從入門到精通(視頻教學版)
- Learning Network Forensics
- SQL Server 2012數據庫管理與開發項目教程
- Oracle GoldenGate 12c Implementer's Guide
- Frank Kane's Taming Big Data with Apache Spark and Python
- Django實戰:Python Web典型模塊與項目開發
- Scratch·愛編程的藝術家
- Swift語言實戰晉級
- HTML5移動前端開發基礎與實戰(微課版)