[ltp] initial state vs. state transitions

Henrique de Moraes Holschuh linux-thinkpad@linux-thinkpad.org
Tue, 30 Dec 2008 01:26:09 -0200


On Mon, 29 Dec 2008, David Abrahams wrote:
> > We query the initial state at boot and set it... 
> 
> Who queries it?  Who is "we" in this case?

The people writing scripts, inside the scripts.  If they did their job
right.  Which is not something you can take for granted.

> Does this setting of the initial state trigger acpi or pm state
> transition hooks?

No, and it wouldn't help that much, for various reasons, the main one
being that it is hard to get this right, and applications would
still need to do special processing to request the first event, and
to wait for it before doing anything else.

So, each and *every* application must query the initial state when it
starts, and take the required actions for that initial state.  That's
a much simpler, fail-proof, and race-proof way of doing things.

It means that, for example, an application based on shell scripts
hooked to acpid has to be broken into at least TWO parts: something
that runs at system startup, and something that gets called by acpid
asyncronously when events happen.

Well, one could argue acpid could have made THAT easier to do.

> My concern is that to say "put the system in state X when on battery
> power" seems t require installing a transition hook and... something
> else.  What, I am not sure.

I personally go with initscripts, because I do like these things to be
tied to the system and acpid.  Elaborate setups tied to user-based
configs need to do it at system startup (or the system wouldn't be
fully functional while waiting for someone to log in!) and also when
the user logs in.

-- 
  "One disk to rule them all, One disk to find them. One disk to bring
  them all and in the darkness grind them. In the Land of Redmond
  where the shadows lie." -- The Silicon Valley Tarot
  Henrique Holschuh