我想增加一个进程的I / O优先级。答案为.NET和Windows Vista将是很好。 processexplorer是确定的为好。
I want to increase the I/O priority of a process. Answers for both .NET and Windows Vista would be nice. processexplorer is ok as well.
相关信息似乎有点散乱相比通常的MS文档。有这样白皮书讨论I/O优先级在Windows 。该文档似乎有测试标志了这一切,但我想这可能主要是pretty的准确。
The relevant information seems to be a bit scattered compared to the usual MS documentation. There is this white paper that discusses I/O Prioritization in windows. This doc seems to have beta flags all over it but I guess it's probably mostly pretty accurate.
两个重要的事情需要注意:
Two important things to note:
您只能减少低于正常IO请求的优先级。 在驱动程序可以忽略任何这样的请求,并把它当作正常的反正。客户端应用程序有用的API是SetFileInformationByHandle:
The useful APIs for client applications are SetFileInformationByHandle:
FILE_IO_PRIORITY_HINT_INFO priorityHint;
priorityHint.PriorityHint = IoPriorityHintLow;
result = SetFileInformationByHandle( hFile,
FileIoPriorityHintInfo,
&priorityHint,
sizeof(PriorityHint));
SetPriorityClass :
// reduce CPU, page and IO priority for the whole process
result = SetPriorityClass( GetCurrentProcess(),
PROCESS_MODE_BACKGROUND_BEGIN);
// do stuff
result = SetPriorityClass( GetCurrentProcess(),
PROCESS_MODE_BACKGROUND_END);
SetThreadPriority函数这是类似的:
// reduce CPU, page and IO priority for the current thread
SetThreadPriority(GetCurrentThread(), THREAD_MODE_BACKGROUND_BEGIN);
// do stuff
SetThreadPriority(GetCurrentThread(), THREAD_MODE_BACKGROUND_END);
SetFileBandwithReservation:
// reserve bandwidth of 200 bytes/sec
result = SetFileBandwidthReservation( hFile,
1000,
200,
FALSE,
&transferSize,
&outstandingRequests );
对于.NET做平常的东西以P / Invoke的。
For .Net do the usual stuff with P/Invoke.