views:

226

answers:

2

I have a background thread that performs I/O operations (keeping an index up to date). But in addition to that several clients access the server's hard disk and I want these accesses as fast as possible. So I thought, it would be nice, if the indexing thread is only running when the I/O load is low.

Is there a way to figure this out?

I'm open for alternative suggestions as well.

+5  A: 

Setting your threads priority to idle should be sufficient.


Edit

You are right about the fact that the thread's priority does not impact the IO priority.
Take a look at I/O Prioritization in Windows Vista for a detailed explanation.

Lieven
Hi! I always thought the priority would only control cpu times? In what way and to what extent does I/O influence the scheduling decicions?
Smasher
+1 Thanks by the way :)
Smasher
Under Vista, processes with lower thread priority also have lower I/O priority.
Dave Van den Eynde
What about XP then? Any possible solutions?
Smasher
@Dave Van den Eynde: as I interpretate it, this could lead to blocking a high priority thread waiting for the low priority thread releasing its resource.
Lieven
+7  A: 

Use Performance Counters to get the I/O activity of the disks. Once it gets to the low-end of your threshold, allow your threads to run. Don't forget to take into account your own I/O load you'll be adding when deciding what your high-end is for the stopping threshold.

Erich Mirabal
I guess you are talking about http://msdn.microsoft.com/en-us/library/aa373083(VS.85).aspx ? I have to look for more resources on this topic...do you have any links?
Smasher
A, while I was writing my answer ;-) +1 then for you.
mghie
Yeah, that link is a start. I know you are in Delphi, but if you happen to also have VS, open up the "Server Explorer" to peek at some nice PCs available to you. Under the server, "Performance Counters" are there - including the IO for a given process! So actually, you can even focus on just the processes you care about (if you know their info and such).
Erich Mirabal
+1 This is the better solution afaic
Lieven