I am working on QNX 6.5 Operating system. QNX 6.5 supports POSIX APIs. I am trying to build an application which is used to evaluate performance of hard-disks. My application will read/write/read after write a user defined data buffer of size in kB or MB
continuously to the hard-disk from start sector to end sector. The operation performed (read, write, read after write) depends on the user choice. Each time, an operation is
performed, application will keep track of the time using ClockCycles()
and also calculate the speed of each sector read/write operation.
I am using open()
call to open the device file like /dev/hd0
. I am using read()
, write()
APIs to perform read/write operations. My problem is: I am not getting the correct speed of actual disk read/write. Actually the application is returning the speed of data read/write to cache often. The issue is more clear when I am trying to perform an immediate read after write operation. The speed of read operation just after a write operation is very high of the order of 1000-1200 MB/S; whereas a normal read is taking
50-60 MB/S. I am using open flags like O_SYNC
and O_RDWR
. I have also tried to change the flags to O_DSYNC
and O_RSYNC
. But I found the flags have no effect in the output of the application. There is no flag equivalent of O_DIRECT
like in Linux.
I have also tried to disable cache in hard-disk driver during bootup. Then I got read/write speed accuracy for data sizes of the order of MBs. But even then, when lower data sizes are read after an immediate write, the read speed is again very high. I have also seen some macros like CACHE_FLUSH
, CACHE_INVALIDATE
for use in drivers which needs DMA transfer. But I don't know how to use these macros in an application. Can anyone please help me how to bypass caching and get the speed of read/write operation to hard-disk? My hard-disk can be either formatted or unformatted. I have tested with both cases.