What Volatile Means (and Doesn't Mean)
What Volatile Means (and Doesn't Mean) Copyright © 2024 by Ben Saks and Dan Saks 0-1 What Volatile Means (and Doesn’t Mean) by Ben Saks and Dan Saks September, 2024 1 Saks & Associates These notes 45504-4906 USA +1-412-521-4117 (voice) service@saksandassociates.com saksandassociates.com 2What Volatile Means (and Doesn't Mean) Copyright © 2024 by Ben Saks and Dan Saks 0-2 Introduction The volatilequalifier provide Workarounds for compiler issues regarding volatile 8What Volatile Means (and Doesn't Mean) Copyright © 2024 by Ben Saks and Dan Saks 0-3 Why volatile is Necessary Many device drivers contain code0 码力 | 32 页 | 901.80 KB | 5 月前3Template Metaprogramming: Type Traits
is_void: cv qualifiers 35• Is void const void? • Is void volatile void? is_void: cv qualifiers 35• Is void const void? • Is void volatile void? • is_void is in Primary Type Categories is_void: cv cv qualifiers 35• Is void const void? • Is void volatile void? • is_void is in Primary Type Categories is_void: cv qualifiers 35 "For any given type T, the result of applying one of these templates templates to T and to cv T shall yield the same result."• Is void const void? • Is void volatile void? • is_void is in Primary Type Categories • Yes - no matter your opinion ;-) is_void: cv qualifiers 35 "For0 码力 | 403 页 | 5.30 MB | 5 月前3The Zig Programming Language 0.12.0 Documentation
/home/ci/actions-runner/_work/zig-bootstrap/out/host/lib/zig/std/start.zig:253:5: 0x103 asm volatile (switch (native_arch) { ^ All 1 tests passed. 1 errors were logged. 1 tests leaked memory. @intFromPtr C Pointers volatile Loads and stores are assumed to not have side effects. If a given load or store should have side effects, such as Memory Mapped Input/Output (MMIO), use volatile . In the following code: test_volatile.zig const expect = @import("std").testing.expect; test "volatile" { const mmio_ptr: *volatile u8 = @ptrFromInt(0x12345678); try expect(@TypeOf(mmio_ptr) == *volatile u8); }0 码力 | 241 页 | 7.37 MB | 1 年前3The Zig Programming Language 0.11.0 Documentation
Pointers 13.1. volatile Loads and stores are assumed to not have side effects. If a given load or store should have side effects, such as Memory Mapped Input/Output (MMIO), use volatile . In the following in the same order as in source code: test_volatile.zig 1 const expect = @import("std").testing.expect; 2 3 test "volatile" { 4 const mmio_ptr: *volatile u8 = @ptrFromInt(0x12345678); 5 try expect(@TypeOf(mmio_ptr) == *volatile u8); 6 } Shell $ zig test test_volatile.zig 1/1 test.volatile... OK All 1 tests passed. Note that volatile is unrelated to concurrency and Atomics. If you see0 码力 | 238 页 | 7.80 MB | 1 年前3CppCon 2021: Persistent Data Structures
a new tier in the memory hierarchy that delivers capacity of non-volatile storage at speeds close to DRAM ▶ Benefits: ▶ Non-volatile storage ▶ Byte addressable ▶ Provides higher density than DRAM ▶ Has Capacity ~10ms ~100ms 10-100µs ~80-100ns 1-10ns ~0.1ns Volatile Memory Load/Store Instructions Cache Line Granularity Non-Volatile Memory I/O Commands Block Granularity Figure 1: Traditional Memory Hierarchy ~10ms ~100ms 10-100µs ~80-100ns 1-10ns ~0.1ns Volatile Memory Load/Store Instructions Cache Line Granularity Non-Volatile Storage I/O Commands Block Granularity CPU Registers CPU Caches0 码力 | 56 页 | 1.90 MB | 5 月前3Comprehensive Rust(Persian ) 202412
aliases exist . unsafe } pin_cnf_21.write_volatile ) DIR_OUTPUT | INPUT_DISCONNECT | PULL_DISABLED | DRIVE_S0S1 | SENSE_DISABLED , ( ; pin_cnf_28.write_volatile ) DIR_OUTPUT | INPUT_DISCONNECT | PULL_DISABLED control registers, and no / / aliases exist . unsafe } gpio0_outclr.write_volatile(1 << 28 ( ; gpio0_outset.write_volatile(1 << 21 ( ; { loop } { { • � � GPIO 0 � � � � �� � � � � � � � � � � � � � � � � . 53.3 � � � � � � � � � � � � � � � � � � � � � MMIO • � � pointer::read_volatile � pointer::write_volatile � � � � � � � � � � � . • � � � � reference � � � � � � � � � � � � � . • addr_of0 码力 | 393 页 | 987.97 KB | 10 月前3Comprehensive Rust(Ukrainian) 202412
псевдонімів не існує. unsafe { pin_cnf_21.write_volatile( DIR_OUTPUT | INPUT_DISCONNECT | PULL_DISABLED | DRIVE_S0S1 | SENSE_DISABLED, ); pin_cnf_28.write_volatile( DIR_OUTPUT | INPUT_DISCONNECT | PULL_DISABLED регістри // керування, і ніяких псевдонімів не існує. unsafe { gpio0_outclr.write_volatile(1 << 28); gpio0_outset.write_volatile(1 << 21); } loop {} } 279 • Вивід 21 GPIO 0 підключений до першого стовпчика Здійснення непостійного доступу до пам'яті для MMIO • Використовуйте pointer::read_volatile та pointer::write_volatile. • Ніколи не тримайте посилання. • Використовуйте &raw для отримання полів структур0 码力 | 396 页 | 1.08 MB | 10 月前3Data Is All You Need for Fusion
code is about Hardware Matrix Multiply #define macro_n4 {\ b_pref = b_ptr + 4 * K;\ __asm__ __volatile__(\ "movq %7,%%r15; movq %1,%%r14; movq %6,%%r11; salq £4,%%r11;"\ "cmpq £24,%%r15; jb 3243431f;"\ b_ptr += 4 * K; c_ptr += 4 * ldc - M;\ } #define macro_n2 {\ b_pref = b_ptr + 2 * K;\ __asm__ __volatile__(\ "movq %7,%%r15; movq %1,%%r14; movq %6,%%r11; salq £4,%%r11;"\ "cmpq £24,%%r15; jb 3243231f;"\ code is about Hardware Matrix Multiply #define macro_n4 {\ b_pref = b_ptr + 4 * K;\ __asm__ __volatile__(\ "movq %7,%%r15; movq %1,%%r14; movq %6,%%r11; salq £4,%%r11;"\ "cmpq £24,%%r15; jb 3243431f;"\0 码力 | 151 页 | 9.90 MB | 5 月前3C++ Memory Model: from C++11 to C++23
and writes) to volatile objects occur strictly according to the semantics of the expressions in which they occur. In particular, they are not reordered with respect to other volatile accesses on the | alex.dathskovsky@speedata.io | www.linkedin.com/in/alexdathskovsky Volatile ● Volatile is not a synchronization tool ● Volatile doesn’t affect threading ● It's not an atomic value ● It doesn’t add barriersAlex Dathskovsky | alex.dathskovsky@speedata.io | www.linkedin.com/in/alexdathskovsky Volatile: what is it good for? ● Tells the compiler it shouldn’t optimize the memory reads and writes0 码力 | 112 页 | 5.17 MB | 5 月前3The Zig Programming Language 0.4.0 Documentation
Floating Point Operations Operators Table of Operators Precedence Arrays Vectors SIMD Pointers volatile Alignment allowzero Slices struct extern struct packed struct struct Naming enum extern enum Zero Bit Types volatile Loads and stores are assumed to not have side effects. If a given load or store should have side effects, such as Memory Mapped Input/Output (MMIO), use volatile. In the following debug.assert; test "volatile" { const mmio_ptr = @intToPtr(*volatile u8, 0x12345678); assert(@typeOf(mmio_ptr) == *volatile u8); } $ zig test test.zig Test 1/1 volatile...OK All tests passed0 码力 | 207 页 | 5.29 MB | 1 年前3
共 409 条
- 1
- 2
- 3
- 4
- 5
- 6
- 41