[fpc-pascal] Writing to a drive which may be spun down
bo.berglund at gmail.com
Thu Nov 21 10:15:10 CET 2019
On Thu, 21 Nov 2019 01:16:16 -0500, Brian
<b_lists at patandbrian.org> wrote:
>Running Ubuntu 18 LTS, I have a console-mode number-cruncher which
>writes occasional output files. It works just fine if the output is
>directed to a drive which is permanently spun up, but can fail if the
>output is directed to a USB drive (by which I mean a USB-connected 8TB
>external drive, not one of the keydrives). I've followed things
>through with the debugger, and it seems that the problem occurs when
>the drive has powered itself down due to lack of accesses. The assign
>and rewrite work OK, but then the first attempt to write to the file
>fails with a 'No such file' error. Putting a large (30 second!) delay
>before the first write means everything works OK, presumably because
>the drive gets time to spin up again.
>My question: Is there a standard method for handling this situation,
>i.e. making sure that a drive has not spun down, or is it just a case
>of writing a wrapper round the write function and handling the 'No
>such file' error with a wait and a retry?
Maybe not a solution here but I have experienced the same kind of
problem on my Windows 7 laptop where I have a 2TB data drive where all
my work is being done. Compilations and other similar tasks were
annoyingly slow to start when I discovered that Windows7 had spun down
the drive and no matter what I did to change settings it would not
So I created a very small FPC program that writes and reads back one
byte to a file on the drive every 10 seconds and measures the latency
(using gettickcount) to use to display the max/min and average delays.
When this is running (it is in my startup) I no longer have these
startup problems of the drive.
Right now it has accumulated 35510 access time values which average 15
ms with a max of 327 ms. All since the last reboot.
Developer in Sweden
More information about the fpc-pascal