linux kernel aio functionality

后端 未结 1 603
日久生厌
日久生厌 2020-12-25 08:28

I am testing kernel asynchronous io functions (not posix aio) and am trying to figure out how it works. The code below is a complete program where I simply write an array re

相关标签:
1条回答
  • 2020-12-25 09:11

    First of all, good job using libaio instead of POSIX aio.

    Are there any restrictions on the usage of O_DIRECT ?

    I'm not 100% sure this is the real problem, but O_DIRECT has some requirements (quoting mostly from TLPI):

    • The data buffer being transferred must be aligned on a memory boundary that is a multiple of the block size (use posix_memalign)
    • The file or device offset at which data transfer commences must be a multiple of the block size
    • The length of the data to be transferred must be a multiple of the block size

    At a glance, I can see you are not taking aby precautions to align memory in allocate_2D_matrix.

    If I do not open the file using O_DIRECT, things work fine, but it beats the purpose of having async writes.

    This happens not to be the case. Asynchronous I/O works well without O_DIRECT (for instance think of the number of system calls slashed).

    0 讨论(0)
提交回复
热议问题