From: William Mitchell on
Jolly Roger <jollyroger(a)null.org> writes:

> On 2006-09-10 18:10:56 -0500, "Wayne C. Morris"
> <wayne.morris(a)this.is.invalid> said:
>
> > In article <2006091011514470243-jollyroger(a)nullorg>,
> > Jolly Roger <jollyroger(a)null.org> wrote:
> >
> >> The real question I have is: How, specifically, does the Mac
> >> determine whether or not a clean shutdown happened on power up?
> > It reads a flag that's stored on the disk.
> > When anything on the disk is modified, the OS changes the flag to
> > "dirty".
> > When the disk is ejected cleanly, either manually or during a
> > shutdown/restart, the OS sets the drive's flag to "clean".
> > When the disk is mounted again, the OS checks the flag. If it's
^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
> > "dirty", the OS scans the disk and tries to fix any problems. After
> > it fixes the disk, it marks it as "clean".
>
> That's not the question I was asking - I guess I should have phrased
> it differently. Here's my *real* real question:
>
> How does the Mac PMU determine whether or not the last shutdown was a
> clean shutdown as opposed to a power failure?
>

"When the disk is mounted again, the OS checks the flag."


--
Bill Mitchell
Dept of Mathematics, The University of Florida
PO Box 118105, Gainesville, FL 32611--8105
mitchell(a)math.ufl.edu (352) 392-0281 x284
From: Jolly Roger on
On 2006-09-10 20:41:10 -0500, William Mitchell <mitchell(a)math.ufl.edu> said:

> Jolly Roger <jollyroger(a)null.org> writes:
>
>> On 2006-09-10 18:10:56 -0500, "Wayne C. Morris"
>> <wayne.morris(a)this.is.invalid> said:
>>
>>> In article <2006091011514470243-jollyroger(a)nullorg>,
>>> Jolly Roger <jollyroger(a)null.org> wrote:
>>>
>>>> The real question I have is: How, specifically, does the Mac
>>>> determine whether or not a clean shutdown happened on power up?
>>> It reads a flag that's stored on the disk.
>>> When anything on the disk is modified, the OS changes the flag to
>>> "dirty".
>>> When the disk is ejected cleanly, either manually or during a
>>> shutdown/restart, the OS sets the drive's flag to "clean".
>>> When the disk is mounted again, the OS checks the flag. If it's
> ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
>>> "dirty", the OS scans the disk and tries to fix any problems. After
>>> it fixes the disk, it marks it as "clean".
>>
>> That's not the question I was asking - I guess I should have phrased
>> it differently. Here's my *real* real question:
>>
>> How does the Mac PMU determine whether or not the last shutdown was a
>> clean shutdown as opposed to a power failure?
>>
>
> "When the disk is mounted again, the OS checks the flag."

Apparently I am unable to sufficiently explain my question. : ( I'll
try once more (after that, I give up)!

I am referring to the "Automatically restart after power failure"
feature, where the PMU somehow knows whether or not a power outage
occurred the last time there was power. How does it know this?

--
-JR

From: Heath Raftery on
Jolly Roger <jollyroger(a)null.org> wrote:
> On 2006-09-10 20:41:10 -0500, William Mitchell <mitchell(a)math.ufl.edu> said:
>
>> Jolly Roger <jollyroger(a)null.org> writes:
>>
>>> On 2006-09-10 18:10:56 -0500, "Wayne C. Morris"
>>> <wayne.morris(a)this.is.invalid> said:
>>>
>>> That's not the question I was asking - I guess I should have phrased
>>> it differently. Here's my *real* real question:
>>>
>>> How does the Mac PMU determine whether or not the last shutdown was a
>>> clean shutdown as opposed to a power failure?
>>>
>>
>> "When the disk is mounted again, the OS checks the flag."
>
> Apparently I am unable to sufficiently explain my question. : ( I'll
> try once more (after that, I give up)!

I thought you explained fine. I'm not sure why people keep
suggesting a disk based solution. Obviously the PMU is able to
determine whether the last shutdown was "clean" without powering
the computer up (to read the disk for example). If the Energy
Saver setting says so, the PMU will then power the computer up.

My contribution is this: I suspect the PMU reads the nvram when
it receives power. The nvram is a "non-volatile" memory meaning
it's contents survive a power cycle, similar to PRAM.
Unfortunately, now that I look (using nvram -p in Terminal) I
can't see the setting the appropriate setting. It is not
"auto-boot?" because that determines whether an OS is
automatically booted or the Open Firmware prompt is displayed.

I have a hunch that during the process of a shutdown, a setting
in this nvram is flipped. This is what the PMU would check. I'm
curious to see if anyone can find this trigger or when it is
triggered.

--
*--------------------------------------------------------*
| ^Nothing is foolproof to a sufficiently talented fool^ |
| Heath Raftery, HRSoftWorks _\|/_ |
*______________________________________m_('.')_m_________*