Linux/Documentation/io_ordering.txt

Chinese translated version of Linux/Documentation/io_ordering.txt

If you have any comment or update to the content, please contact theoriginal document maintainer directly.  However, if you have a problem communicating in English you can also ask the Chinese  maintainer forhelp.  Contact the Chinese maintainer if this translation is outdatedor if there is a problem with the translation. Chinese maintainer: 张凯 zhangking520@gmail.com  ---------------------------------------------------------------------

Linux/Documentation/io_ordering.txt 的中文翻译 如果想评论或更新本文的内容,请直接联系原文档的维护者。如果你使用英文 交流有困难的话,也可以向中文版维护者求助。如果本翻译更新不及时或者翻 译存在问题,请联系中文版维护者。 中文版维护者:张凯 zhangking520@gmail.com 中文版翻译者: 张凯 zhangking520@gmail.com 以下为正文 ---------------------------------------------------------------------

 On some platforms, so-called memory-mapped I/O is weakly ordered.  On such
 platforms, driver writers are responsible for ensuring that I/O writes to
 memory-mapped addresses on their device arrive in the order intended.  This is
 typically done by reading a 'safe' device or bridge register, causing the I/O
 chipset to flush pending writes to the device before any reads are posted.  A
 driver would usually use this technique immediately prior to the exit of a
 critical section of code protected by spinlocks.  This would ensure that
 subsequent writes to I/O space arrived only after all prior writes (much like a
 memory barrier op, mb(), only with respect to I/O).
 在一些平台上,所谓的io内存映射不是有序的。在这样的平台,驱动程序编写者有责任确保I / O写入
 他们的设备上的内存映射地址到达的顺序。这是通常是通过阅读“安全”设备或桥梁寄存器,导致I/ O
 芯片组刷新等待写入到设备之前读取时间。 驱动程序通常会立即使用这种技术出口的前旋锁保护的代码的关键部分。
 这将确保后续写入I / O空间后,才抵达之前写(很像的内存屏障运算,MB(),只涉及到I / O)。
 
  A more concrete example from a hypothetical device driver:
 一个具体的例子来自一个虚构的设备驱动
          ...
  CPU A:  spin_lock_irqsave(&dev_lock, flags)
  CPU A:  val = readl(my_status);
  CPU A:  ...
  CPU A:  writel(newval, ring_ptr);
  CPU A:  spin_unlock_irqrestore(&dev_lock, flags)
          ...
  CPU B:  spin_lock_irqsave(&dev_lock, flags)
  CPU B:  val = readl(my_status);
  CPU B:  ...
  CPU B:  writel(newval2, ring_ptr);
  CPU B:  spin_unlock_irqrestore(&dev_lock, flags)
          ...
  
  In the case above, the device may receive newval2 before it receives newval,
  which could cause problems.  Fixing it is easy enough though:
  上面的例子,设备可能在接受地一个变量前,收到第二个变量,而引起问题。下面是解决方案
          ...
  CPU A:  spin_lock_irqsave(&dev_lock, flags)
  CPU A:  val = readl(my_status);
  CPU A:  ...
  CPU A:  writel(newval, ring_ptr);
  CPU A:  (void)readl(safe_register); /* maybe a config register? */
  CPU A:  spin_unlock_irqrestore(&dev_lock, flags)
          ...
  CPU B:  spin_lock_irqsave(&dev_lock, flags)
  CPU B:  val = readl(my_status);
  CPU B:  ...
  CPU B:  writel(newval2, ring_ptr);
  CPU B:  (void)readl(safe_register); /* maybe a config register? */
  CPU B:  spin_unlock_irqrestore(&dev_lock, flags)
  
  Here, the reads from safe_register will cause the I/O chipset to flush any
  pending writes before actually posting the read to the chipset, preventing
  possible data corruption.
  这里,从安全寄存器读取会导致I/ O芯片组,来清除任何挂起的写入操作,在实际上张贴读的芯片组前,以防止可能的数据损坏。

                
  • 0
    点赞
  • 0
    收藏
    觉得还不错? 一键收藏
  • 0
    评论
将QT += core QT -= gui CONFIG += c++11 TARGET = UavRectifyLoadLIb CONFIG += console CONFIG -= app_bundle TEMPLATE = app SOURCES += main.cpp # The following define makes your compiler emit warnings if you use # any feature of Qt which as been marked deprecated (the exact warnings # depend on your compiler). Please consult the documentation of the # deprecated API in order to know how to port your code away from it. DEFINES += QT_DEPRECATED_WARNINGS win32{ CONFIG(debug, debug|release){ DESTDIR = $$PWD/../../../../RasterManager/bin/Debug } else{ DESTDIR = $$PWD/../../../../RasterManager/bin/release } INCLUDEPATH += $$PWD/../../../include/gdal1101 DEPENDPATH += $$PWD/../../../include/gdal1101 } else{ CONFIG(debug, debug|release){ DESTDIR = $$PWD/../../../product/release32 } else{ DESTDIR = $$PWD/../../../product/release32 } } # You can also make your code fail to compile if you use deprecated APIs. # In order to do so, uncomment the following line. # You can also select to disable deprecated APIs only up to a certain version of Qt. #DEFINES += QT_DISABLE_DEPRECATED_BEFORE=0x060000 # disables all the APIs deprecated before Qt 6.0.0 unix:!macx: LIBS += -L$$PWD/../../../product/release32/ -lUAVAutoRectifyMt -lUAVAutoRectify -lUAVAutoRectifyFi INCLUDEPATH += $$PWD/../include DEPENDPATH += $$PWD/../include unix:!macx: LIBS += -L$$PWD/../../../lib/opencvf249/ -lopencv_core unix:!macx: LIBS += -L$$PWD/../../../lib/opencvf249/ -lopencv_highgui unix:!macx: LIBS += -L$$PWD/../../../lib/opencvf249/ -lopencv_imgproc INCLUDEPATH += $$PWD/../../../lib/opencvf249 DEPENDPATH += $$PWD/../../../lib/opencvf249 unix:!macx: LIBS += -L$$PWD/../../../../../../../usr/local/lib/ -lopencv_core #unix:!macx: LIBS += -L$$PWD/../../../../../../../usr/local/lib/ -lopencv_highgui unix:!macx: LIBS += -L$$PWD/../../../../../../../usr/local/lib/ -lopencv_imgproc unix:!macx: LIBS += -L$$PWD/../../../../../../../usr/local/lib/ -lopencv_features2d unix:!macx: LIBS += -L$$PWD/../../../../../../../usr/local/lib/ -lopencv_imgcodecs INCLUDEPATH += $$PWD/../../../../../../../usr/local/include DEPENDPATH += $$PWD/../../../../../../../usr/local/include unix:!macx: LIBS += -L$$PWD/../../../product/release32/ -lDEMDriver unix:!macx: LIBS += -L$$PWD/../../../product/release32/ -lProjection unix:!macx: LIBS += -L$$PWD/../../../product/release32/ -lIImage_gC QMAKE_CXXFLAGS_RELEASE = $$QMAKE_CFLAGS_RELEASE_WITH_DEBUGINFO QMAKE_LFLAGS_RELEASE = $$QMAKE_LFLAGS_RELEASE_WITH_DEBUGINFO 转为cmake格式
最新发布
06-11
根据给出的代码,可以将其转化为以下CMake代码: ``` cmake_minimum_required(VERSION 3.5) project(UavRectifyLoadLIb LANGUAGES CXX) set(CMAKE_CXX_STANDARD 11) set(CMAKE_CXX_STANDARD_REQUIRED ON) set(CMAKE_AUTOMOC ON) set(CMAKE_AUTORCC ON) set(CMAKE_AUTOUIC ON) find_package(Qt5Core REQUIRED) add_executable(UavRectifyLoadLIb main.cpp ) target_link_libraries(UavRectifyLoadLIb PRIVATE Qt5::Core UAVAutoRectifyMt UAVAutoRectify UAVAutoRectifyFi DEMDriver Projection IImage_gC opencv_core opencv_highgui opencv_imgproc opencv_features2d opencv_imgcodecs ) target_include_directories(UavRectifyLoadLIb PRIVATE ${CMAKE_CURRENT_SOURCE_DIR}/../../../include/gdal1101 ${CMAKE_CURRENT_SOURCE_DIR}/../include ${CMAKE_CURRENT_SOURCE_DIR}/../../../lib/opencvf249 ${CMAKE_CURRENT_SOURCE_DIR}/../../../../../../../usr/local/include ) if(UNIX AND NOT APPLE) target_link_directories(UavRectifyLoadLIb PRIVATE ${CMAKE_CURRENT_SOURCE_DIR}/../../../product/release32 ${CMAKE_CURRENT_SOURCE_DIR}/../../../../../../../usr/local/lib ) endif() if(WIN32) if(CMAKE_BUILD_TYPE STREQUAL "Debug") set_target_properties(UavRectifyLoadLIb PROPERTIES RUNTIME_OUTPUT_DIRECTORY_DEBUG ${CMAKE_CURRENT_SOURCE_DIR}/../../../../RasterManager/bin/Debug ) else() set_target_properties(UavRectifyLoadLIb PROPERTIES RUNTIME_OUTPUT_DIRECTORY_RELEASE ${CMAKE_CURRENT_SOURCE_DIR}/../../../../RasterManager/bin/release ) endif() else() if(CMAKE_BUILD_TYPE STREQUAL "Debug") set_target_properties(UavRectifyLoadLIb PROPERTIES RUNTIME_OUTPUT_DIRECTORY_DEBUG ${CMAKE_CURRENT_SOURCE_DIR}/../../../product/release32 ) else() set_target_properties(UavRectifyLoadLIb PROPERTIES RUNTIME_OUTPUT_DIRECTORY_RELEASE ${CMAKE_CURRENT_SOURCE_DIR}/../../../product/release32 ) endif() endif() ```

“相关推荐”对你有帮助么?

  • 非常没帮助
  • 没帮助
  • 一般
  • 有帮助
  • 非常有帮助
提交
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值