views:

406

answers:

2

I have dynamic array filled with bytes, which are read from .raw file with BlockRead() and this operation, logically, requires hell of a Shell resources and I wanted to know if there is any methods to reserve some amount or limit maximum amount of Read/Write/Seek used for Program run time from Hard Disk Drive***

[Clarification]: I meant to set maximum reading speed from HDD while performing action with windows shell / internal app resources. In this moment app is very sensitive to hdd's performance, but it causes on several machines to freeze / lock because system cannot manage disk operations...

I wanted to know about any methods, tutorials, in worst case unit in which function declarations and class info can be found.

As much I know, Pascal as the base of Delphi does not provide very easy approach as the best could be TStream or TPipeline usage (TSocket should not be good, right?)... As much I have used streams, I did not like it because there were some underwater stones with TFileStream ...

Anyway - please give me at least intro to disk performance management...

A: 

RE: "I meant to set maximum reading speed from HDD..."

Just do the throttling yourself. Do disk access in the background thread and throttle operations according to whatever throughput you need.

gabr
A: 

I'm afraid there's no way to throttle the IO activity using the Windows API or some Delphi function. (Unlike threads for example)

You can only slow down your IO accesses by adding Sleep commands or something similar into your code.

You could read the current IO activity using WMI and increase your delays if there's high IO activity.

DR
hm, nop, sleep is the thing that ( imho ) should be avoided as goto in programming whastover. Only possible solution is pretty platform-dependedt. Thats bad. I think I will be forced to go hard way - through WMI SnapIn accessing ... "delays", btw - You mean Seeking or moving through sectors in hdd?
HX_unbanned
Yes, that's why I added "something" similar.
DR
hm, OK, I suppose I'll have to start browsing in MSDN resources and to read multithreading manuals ... too bad there almost everything is focused in C ( fourtinetly multithreading manuals is for Delphi, too ).
HX_unbanned
Actually, Vista introduces I/O prioritisation, see http://technet.microsoft.com/en-gb/magazine/2007.02.vistakernel.aspx, the last section "I/O priority". But "several machines to freeze / lock because system cannot manage disk operations" sounds much more like a problem in the programming, which should be fixed first.
mghie
@HX_unbanned: Your statement about sleep gave me something to think about and I added a SO question for that topic: http://stackoverflow.com/questions/1096794/is-sleep-evil
DR
@DE, Heh, glad to see that my question has become usefull and makes people think deeper and take a look to question from other aspects :) I'll read it asap, mate. Thanks for notification ... @mghie, well, sort of yes - it is code bug, because I write app on XP Environoment and this lock sometimes is only introduced in Windows 6.x OSes. Mainly my guess is that direct access with BlockRead() with DWORD size makes disk caching pretty hard... Ok, thanks for techent link, I had not time to do some msdn/connect/techent research about i/o ...
HX_unbanned