Re: [PATCH 01/13] PM: Add wake lock api.

Rafael J. Wysocki
2009-02-09T00:03:44Z

On Sunday 08 February 2009, Pavel Machek wrote:
> Hi!
>
> > >> > If my understanding is correct, a wakelock is a mechanism that, if held, will
> > >> > prevent the system from (automatically) entering a sleep state, but why do we
> > >> > need a number of such wakelocks instead of just one reference counter with the
> > >> > rule that (automatic) suspend can only happen if the counter is zero?
> > >>
> > >> Using wakelocks instead of a global reference count ensures that your
> > >> request cannot be cleared by someone else.
> > >
> > > Decreasing the refcount without increasing it would have been a bug, IMO.
> >
> > Yes, but if all you have is a global reference count, you can't tell
> > where the bug is.
> ...
> > >> and detailed stats.
> > >
> > > Well, I'm not sure how this is useful in the long run.
> >
> > You may want to know which app drained your battery.
>
> _If_ we want to allow userspace to hold wakelocks (better name could
> be awakelock or nosleeplock?) then some way of displaying them is
> required.

BTW, I don't like the name "wakelocks" at all. They are not locks in the
traditional sense, they are just flags preventing something (suspend) from
happening.

Thanks,
Rafael