Hello
I'm currently writing a software to test the integrity of flash-memory devices. (using c++ iostreams)
To achieve this goal files with random content are written to the device, read back, copied, moved, compared ( I put the device under stress condition, and check if the data is valid from time to time)...
Everything looks great on the outside, but there is a problem behind the curtains.
When I analyzed the commands that are sent to the device over the ATA / SATA Cable (with a Bus Doctor), I discovered that (especially) read commands are often not executed. Nevertheless the data is availible to the program. So they have to come from a buffer, which is not acceptable in my case. Whenever I read Data it has to come straight from the disk, not from the cache. Read / Write Performance isn't important at all.
But I haven't found a way to tell Windows not to buffer anything (There is the option to deactivate write caching for a specific device in the device manager, but doesn't have the desired effect).
If anyone knows how to do this: Please tell me
( same goes for any advice concerning Linux. I think I will run into the same problems there )
Only solution I could come up with so far is Direct I/O.
What I found for Windows is this:
http://www.internals.com/utilities_main.htm
The WinIo library allows 32-bit Windows applications to directly access I/O ports and physical memory. It bypasses Windows protection mechanisms by using a combination of a kernel-mode device driver and several low-level programming techniques.
Direct I/O is the world's first device driver for Microsoft Windows NT, Windows 2000, Windows XP and Windows Server 2003 which enables the direct hardware access for your existing software without any programming efforts on your side
Questions:
Has somebody ever had a similar problem, and can give me some advice?
Do I really have to go with Direct I/O or is there some OS option/setting I haven't found (Windows or Linux)
Do you know other libraries for Direct I/O (Windows or Linux or even better: both)