LINUX DEVICE DRIVERS 3rd edition phần 5

Trong khi đó, nhân dân tệ ngăn chặn các sắp xếp lại của tất cả các lần đọc qua rào, read_barrier_depends khối chỉ sắp xếp lại lần đọc phụ thuộc vào dữ liệu từ lần đọc khác. Sự phân biệt là tinh tế, và nó không tồn tại trên tất cả các kiến trúc. Trừ khi bạn hiểu chính xác những gì đang xảy ra, | prior to the execution of any subsequent read. wmb guarantees ordering in write operations and the mb instruction guarantees both. Each of these functions is a superset of barrier. read_barrier_depends is a special weaker form of read barrier. Whereas rmb prevents the reordering of all reads across the barrier read_barrier_depends blocks only the reordering of reads that depend on data from other reads. The distinction is subtle and it does not exist on all architectures. Unless you understand exactly what is going on and you have a reason to believe that a full read barrier is exacting an excessive performance cost you should probably stickto using rmb. void smp_rmb void void smp_read_barrier_depends void void smp_wmb void void smp_mb void These versions of the barrier macros insert hardware barriers only when the kernel is compiled for SMP systems otherwise they all expand to a simple barrier call. A typical usage of memory barriers in a device driver may have this sort of form writel dev- io_destination_address writel dev- io_size writel dev- DEV_READ wmb writel dev- DEV_GO In this case it is important to be sure that all of the device registers controlling a particular operation have been properly set prior to telling it to begin. The memory barrier enforces the completion of the writes in the necessary order. Because memory barriers affect performance they should be used only where they are really needed. The different types of barriers can also have different performance characteristics so it is worthwhile to use the most specific type possible. For example on the x86 architecture wmb currently does nothing since writes outside the processor are not reordered. Reads are reordered however so mb is slower than wmb . It is worth noting that most of the other kernel primitives dealing with synchronization such as spinlock and atomic_t operations also function as memory barriers. Also worthy of .

Không thể tạo bản xem trước, hãy bấm tải xuống
TỪ KHÓA LIÊN QUAN
TÀI LIỆU MỚI ĐĂNG
Đã phát hiện trình chặn quảng cáo AdBlock
Trang web này phụ thuộc vào doanh thu từ số lần hiển thị quảng cáo để tồn tại. Vui lòng tắt trình chặn quảng cáo của bạn hoặc tạm dừng tính năng chặn quảng cáo cho trang web này.