CPU consumption for hard drive scanning

I would like my software that scans the disk structure to run in the background, but lowers the priority for the thread that scans the disk structure is not running. I mean, you still have the feeling that the computer is running and even freezing, even if your program only consumes 1 percent of the CPU. Is it possible to implement "hard disk time consumption" equivalent to CPU consumption in Win32

+2


source to share


2 answers


With Vista, you can lower the I / O priority that is different from the processor priority. http://msdn.microsoft.com/en-us/library/ms686219(VS.85).aspx

SetPriorityClass(GetCurrentProcess(), PROCESS_MODE_BACKGROUND_BEGIN)

      



For XP, 2003 and older, you will need to find another way to throttle your disk activity, such as using Sleep () often.

+5


source


Disk access is usually measured by several different metric transfers per second (which can be broken down into read / write) and data read or written per second. If you want to limit the impact of the scan application on disk, one way to do this is to monitor one (or both) of these metrics, define a reasonable limit, and periodically smooth the stream over a period of time. Nothing you can do to schedule a processor will be efficient for this task except in the most transparent, indirect way.



+1


source







All Articles