[ltp] initial state vs. state transitions

David Abrahams linux-thinkpad@linux-thinkpad.org
Mon, 29 Dec 2008 19:45:37 -0900


on Mon Dec 29 2008, Henrique de Moraes Holschuh <hmh-AT-hmh.eng.br> wrote:

> 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.

Well, I think "these people" might in general be individual users (like
me), because in general, AFAIK Linux doesn't provide
non-programmer-level tools that allow that sort of configuration.  There
are a few of these kinds of state relations I want to set up.

>> 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.

I'm not sure what "applications" means in this context.  I'm talking
about the sort of things that typically get installed in
/etc/pm/power.d, /etc/acpi, and /etc/udev

[By the way, it's almost impossible for me to keep track of these
different mechanisms, and they seem to be proliferating.  Is there
somewhere a guide that ties them all together conceptually?]

> 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.

Yep.

>> 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.  

Wow, yet another pathway.  I am familiar with initscripts but in my
experience they usually start and stop server processes.  How would I
use initscripts with power transitions, etc.?  Or are you suggesting
that initscripts are just used to handle startup states?  Then what
about transitions out of suspend/hibernate?  Should I really be
installing *three* sets of hooks?

-- 
Dave Abrahams
BoostPro Computing
http://www.boostpro.com