Re: [PATCH 06/11] PM: Add user-space wake lock api.

Brian Swetland
2009-01-31T07:24:13Z

[Uli Luckas <u.luckas@road.de>]
> On Wednesday, 14. January 2009, Arve Hjønnevåg wrote:
> > This adds /sys/power/wake_lock and /sys/power/wake_unlock.
> > Writing a string to wake_lock creates a wake lock the
> > first time is sees a string and locks it. Optionally, the
> > string can be followed by a timeout.
> > To unlock the wake lock, write the same string to wake_unlock.
>
> What happens if a process takes a lock and then dies?
> Instead of using sysfs, how about using a device for this purpose which the
> caller has to keep open as long as they want to hold the lock.

On the android platform this is not a concern since only the system
server manages wakelocks directly and processes use a higher level
wakelock api in userspace that is remoted and handles this situation
(the system server knows when a process dies and can clean up).

For more general usage, the fd model does sound nicer, allowing
cleanup-on-exit, etc. Arve -- is there a reason we went with sysfs?

Brian