Muutke küpsiste eelistusi

E-raamat: Rust Atomics and Locks

  • Formaat: 252 pages
  • Ilmumisaeg: 14-Dec-2022
  • Kirjastus: O'Reilly Media
  • Keel: eng
  • ISBN-13: 9781098119416
Teised raamatud teemal:
  • Formaat - PDF+DRM
  • Hind: 40,37 €*
  • * hind on lõplik, st. muud allahindlused enam ei rakendu
  • Lisa ostukorvi
  • Lisa soovinimekirja
  • See e-raamat on mõeldud ainult isiklikuks kasutamiseks. E-raamatuid ei saa tagastada.
  • Formaat: 252 pages
  • Ilmumisaeg: 14-Dec-2022
  • Kirjastus: O'Reilly Media
  • Keel: eng
  • ISBN-13: 9781098119416
Teised raamatud teemal:

DRM piirangud

  • Kopeerimine (copy/paste):

    ei ole lubatud

  • Printimine:

    ei ole lubatud

  • Kasutamine:

    Digitaalõiguste kaitse (DRM)
    Kirjastus on väljastanud selle e-raamatu krüpteeritud kujul, mis tähendab, et selle lugemiseks peate installeerima spetsiaalse tarkvara. Samuti peate looma endale  Adobe ID Rohkem infot siin. E-raamatut saab lugeda 1 kasutaja ning alla laadida kuni 6'de seadmesse (kõik autoriseeritud sama Adobe ID-ga).

    Vajalik tarkvara
    Mobiilsetes seadmetes (telefon või tahvelarvuti) lugemiseks peate installeerima selle tasuta rakenduse: PocketBook Reader (iOS / Android)

    PC või Mac seadmes lugemiseks peate installima Adobe Digital Editionsi (Seeon tasuta rakendus spetsiaalselt e-raamatute lugemiseks. Seda ei tohi segamini ajada Adober Reader'iga, mis tõenäoliselt on juba teie arvutisse installeeritud )

    Seda e-raamatut ei saa lugeda Amazon Kindle's. 

The Rust programming language is extremely well-suited for concurrency, and its ecosystem has many libraries that include lots of concurrent data structures, locks, and more. But implementing those structures correctly can be very difficult. Even in the most well-used libraries, memory ordering bugs are not uncommon.

In this practical book, Mara Bos, leader of the Rust library team, helps Rust programmers of all levels gain a clear understanding of low-level concurrency. You'll learn everything about atomics and memory ordering and how they're combined with basic operating system APIs to build common primitives like mutexes and condition variables. Once you're done, you'll have a firm grasp of how Rust's memory model, the processor, and the roles of the operating system all fit together.

With this guide, you'll learn:

  • How Rust's type system works exceptionally well for programming concurrency correctly
  • All about mutexes, condition variables, atomics, and memory ordering
  • What happens in practice with atomic operations on Intel and ARM processors
  • How locks are implemented with support from the operating system
  • How to write correct code that includes concurrency, atomics, and locks
  • How to build your own locking and synchronization primitives correctly

Foreword xi
Preface xiii
1 Basics of Rust Concurrency
1(30)
Threads in Rust
2(3)
Scoped Threads
5(2)
Shared Ownership and Reference Counting
7(4)
Statics
7(1)
Leaking
8(1)
Reference Counting
8(3)
Borrowing and Data Races
11(2)
Interior Mutability
13(3)
Cell
14(1)
RefCell
14(1)
Mutex and RwLock
15(1)
Atomics
15(1)
UnsafeCell
16(1)
Thread Safety: Send and Sync
16(2)
Locking: Mutexes and RwLocks
18(6)
Rust's Mutex
18(3)
Lock Poisoning
21(1)
Reader-Writer Lock
22(2)
Waiting: Parking and Condition Variables
24(5)
Thread Parking
24(2)
Condition Variables
26(3)
Summary
29(2)
2 Atomics
31(18)
Atomic Load and Store Operations
32(4)
Example: Stop Flag
32(1)
Example: Progress Reporting
33(2)
Example: Lazy Initialization
35(1)
Fetch-and-Modify Operations
36(6)
Example: Progress Reporting from Multiple Threads
38(1)
Example: Statistics
39(2)
Example: ID Allocation
41(1)
Compare-and-Exchange Operations
42(5)
Example: ID Allocation Without Overflow
44(1)
Example: Lazy One-Time Initialization
45(2)
Summary
47(2)
3 Memory Ordering
49(26)
Reordering and Optimizations
49(2)
The Memory Model
51(1)
Happens-Before Relationship
51(3)
Spawning and Joining
53(1)
Relaxed Ordering
54(3)
Release and Acquire Ordering
57(8)
Example: Locking
60(2)
Example: Lazy Initialization with Indirection
62(3)
Consume Ordering
65(1)
Sequentially Consistent Ordering
66(1)
Fences
67(4)
Common Misconceptions
71(2)
Summary
73(2)
4 Building Our Own Spin Lock
75(10)
A Minimal Implementation
75(3)
An Unsafe Spin Lock
78(2)
A Safe Interface Using a Lock Guard
80(3)
Summary
83(2)
5 Building Our Own Channels
85(20)
A Simple Mutex-Based Channel
85(2)
An Unsafe One-Shot Channel
87(3)
Safety Through Runtime Checks
90(4)
Safety Through Types
94(4)
Borrowing to Avoid Allocation
98(3)
Blocking
101(3)
Summary
104(1)
6 Building Our Own "Arc"
105(22)
Basic Reference Counting
105(6)
Testing It
109(1)
Mutation
110(1)
Weak Pointers
111(7)
Testing It
117(1)
Optimizing
118(7)
Summary
125(2)
7 Understanding the Processor
127(34)
Processor Instructions
128(13)
Load and Store
132(1)
Read-Modify-Write Operations
133(4)
Load-Linked and Store-Conditional Instructions
137(4)
Caching
141(8)
Cache Coherence
142(2)
Impact on Performance
144(5)
Reordering
149(1)
Memory Ordering
150(9)
X86-64: Strongly Ordered
151(2)
ARM64: Weakly Ordered
153(2)
An Experiment
155(3)
Memory Fences
158(1)
Summary
159(2)
8 Operating System Primitives
161(20)
Interfacing with the Kernel
161(2)
Posix
163(3)
Wrapping in Rust
164(2)
Linux
166(8)
Futex
167(2)
Futex Operations
169(4)
Priority Inheritance Futex Operations
173(1)
Macos
174(1)
Os_Unfair_Lock
175(1)
Windows
175(4)
Heavyweight Kernel Objects
175(1)
Lighter-Weight Objects
176(1)
Address-Based Waiting
177(2)
Summary
179(2)
9 Building Our Own Locks
181(32)
Mutex
183(10)
Avoiding Syscalls
186(2)
Optimizing Further
188(3)
Benchmarking
191(2)
Condition Variable
193(10)
Avoiding Syscalls
198(2)
Avoiding Spurious Wake-ups
200(3)
Reader-Writer Lock
203(8)
Avoiding Busy-Looping Writers
206(2)
Avoiding Writer Starvation
208(3)
Summary
211(2)
10 Ideas and Inspiration
213(8)
Semaphore
213(1)
RCU
214(1)
Lock-Free Linked List
215(2)
Queue-Based Locks
217(1)
Parking Lot-Based Locks
218(1)
Sequence Lock
218(1)
Teaching Materials
219(2)
Index 221
Mara Bos maintains the Rust standard library and builds real time control systems in Rust. As team lead of the Rust library teams, she knows all the ins and outs of the language and the standard library. In addition, she has been working with concurrent real time systems for years at the company she founded. Maintaining the most-used library in the Rust ecosystem and working daily on safety critical systems has given her the hands-on experience to both understand the theory and bring it to practice.