История изменений
Исправление SZT, (текущая версия) :
но делать два треда, как я сказал, это академически верно, и неизбежно, чтобы не попасть в ад и там жариться вечно.
В винапи есть специальная функция WriteFileEx для асинхронной записи, и там тред должен сам неявно создаваться при ее вызове.
Касательно DMA - там есть ньюанс, что буфер, из которого мы записываем в файл, должен быть особым образом выравнен. Вот что нагуглил https://www.pinvoke.net/default.aspx/kernel32/WriteFile.html
The documentation states that if using unbuffered IO, the memory must be «storage aligned» (aligned to the sector size of the storage device). Either this is not enforced, or managed allocations (specifically byte arrays) are automatically storage aligned because there seems to be no problem using it. Note that storage aligned and page aligned are not the same, and managed allocations are not in general page aligned (required for WriteFileScatter).
In fact the buffer must be aligned to the granularity of the SCSI/IDE adapter's DMA alignment (PDEVICE_OBJECT->AlignmentRequirement). The MSDN documentation is written for the lamers and probably it seemed safe to restrict them using the sector size (which is >= 512 byte, while most modern SCSI cards use <=4 byte requirement).
И тогда по-идее должно DMA задействоваться. В системном программировании под винды я не эксперт, в Borland C++ я тоже не эксперт, и вообще это всё оффтоп. Советую топикстартеру с такими вопросами идти в другие места, например в RSDN
Исходная версия SZT, :
но делать два треда, как я сказал, это академически верно, и неизбежно, чтобы не попасть в ад и там жариться вечно.
В винапи есть специальная функция WriteFileEx для асинхронной записи, и там тред должен сам неявно создаваться при ее вызове.
Касательно DMA - там есть ньюанс, что буфер, из которого мы записываем в файл, должен быть особым образом выравнен. Вот что нагуглил https://www.pinvoke.net/default.aspx/kernel32/WriteFile.html
The documentation states that if using unbuffered IO, the memory must be «storage aligned» (aligned to the sector size of the storage device). Either this is not enforced, or managed allocations (specifically byte arrays) are automatically storage aligned because there seems to be no problem using it. Note that storage aligned and page aligned are not the same, and managed allocations are not in general page aligned (required for WriteFileScatter).
In fact the buffer must be aligned to the granularity of the SCSI/IDE adapter's DMA alignment (PDEVICE_OBJECT->AlignmentRequirement). The MSDN documentation is written for the lamers and probably it seemed safe to restrict them using the sector size (which is >= 512 byte, while most modern SCSI cards use <=4 byte requirement).