开发者

How to use file bandwidth reservation (scheduled file IO) in Windows

I need to implement an application that streams data from disk. It is important that the data throughput is fairly constant and is not interupted by any other activity on the disk.

From Windows Vista onwards, the GetFileBandwidthReservation() and开发者_开发知识库 SetFileBandwidthReservation() functions have been introduced specifically for this purpose. However, I cannot get this to work. I've searched the internet but I cannot find much information on this (and no working code samples seem to exist online).

Code to reproduce:

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);

The call to GetFileBandwidthReservation always returns FALSE which indicates a failure. GetLastError returns 1 which isn't very helpfull. If a try to invoke *Set*FileBandwithReservation I get the same result.

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

Does anybody have any idea of what I am doing wrong? Any help will be greatly appreciated.


This requires support from the disk device driver. The kind of driver that you'd find in an upscale server, not a consumer level machine. Ask more questions about this at serverfault.com

0

上一篇:

下一篇:

精彩评论

暂无评论...
验证码 换一张
取 消

最新问答

问答排行榜