From: Hugo gleaves on


"Francois PIETTE" wrote:

> >> Shutdown is an orderly process. It is clean. No risk to loose data. I
> >> would
> >> even say there is much less risk to loose data when properly shutting
> >> down
> >> the computer (not by removing the power cord or clicking the hardware
> >> reset,
> >> but using the shutdown procedure) than killing a process with task
> >> manager.
>
> > That is more or less what I understood too.
> >
> > Now here is next question, which might explain what is happening.
> >
> > If the app maps a 2 GIG file, then populates say 1 GIG with data, this
> > equates to about 260,000 modified memory pages. Assume the box has lots of
> > memory (eg, 8 or 16 G) and that memory is under very little pressure.
> >
> > Now when the reboot begins, it will go through the orderly termination and
> > flushing you described, but it will take X seconds for all of these
> > modified
> > pages to be written to the disk (the media itself).
> >
> > So there could be a weakness, in that the shutdown will wait only so many
> > seconds and could perhaps power off the box, while these pages are being
> > flkushed, resulting in not all modfied pages being written.
>
> Not sure I understand what you mean.
> No matter how long it will take to write the data to disk, it will be
> written in the shutdown process.
> But if the user is impatient and turn the power off before the shutdown is
> finished, then yes things will go wrong.
>
> --
> francois.piette(a)overbyte.be
> The author of the freeware multi-tier middleware MidWare
> The author of the freeware Internet Component Suite (ICS)
> http://www.overbyte.be
>
>

I think you are correct. I just ran some tests, if I call FlushViewOfFile
explicity then shutdown the system, the app does not vanish from the screen
until the flush finishes, the box then shuts down promptly.

If I dont call FlushViewOfFile, but just start a shutdown, the app's window
vanishes and the system displays the shutdown screen (spinning circle
"Shutting Down").

But this takes a while because the system is flushing to disk implicityly.

In each case the data (several gig in this test) is fully written to disk
before the box is switched off.

This is good.

However, this raises a new question for me, and I can't quite get a definite
answer from the MSDN docs, I'm posting this separately as "Detect If Shutdown
In Progress".

Thanks
H