How to use File Bandwidth Reservation (Scheduled IO File) on Windows

I need to implement an application that transfers data from disk. It is important that the data throughput is constant enough and not interrupted by any other disk activity.

Starting with Windows Vista, the GetFileBandwidthReservation () and SetFileBandwidthReservation () functions have been specifically introduced for this purpose. However, I cannot get this to work. I searched on the Internet, but I cannot find much information about this (and working code samples do not seem to exist on the Internet).

Code to play:

HANDLE h = ::CreateFile(L"D:\\testfile", GENERIC_READ, 0, NULL, OPEN_EXISTING, FILE_FLAG_NO_BUFFERING | FILE_FLAG_SEQUENTIAL_SCAN, NULL); DWORD periodMilliseconds, bytesPerPeriod, transferSize, numOutstandingRequests; BOOL discardable; BOOL result = ::GetFileBandwidthReservation(h, &periodMilliseconds, &bytesPerPeriod, &discardable, &transferSize, &numOutstandingRequests); if (result == FALSE) // result is always false! { DWORD reason = ::GetLastError(); // reason is always 1! std::cout << "Error: " << reason << std::endl; } result = ::CloseHandle(h); 

A call to GetFileBandwidthReservation always returns FALSE, which indicates a failure. GetLastError returns 1, which is not very useful. If I try to call * Set * FileBandwithReservation, I get the same result.

I am testing this on a PC with Windows Server 2008 SP2 (32-bit).

Does anyone have an idea of ​​what I'm doing wrong? Any help would be greatly appreciated.

+4
source share
1 answer

This requires disk driver support. The type of driver that you will find on a high-end server, not at the consumer level. Ask more questions about this on server.com.

+3
source

Source: https://habr.com/ru/post/1335100/