4

I'm working on an embedded linux platform.

When I do "echo "mem" > /sys/power/state", system will suspend.

I know that kernel and driver can know that suspend operation's coming. But would it be possible that a user space process or application can get the notification that the system will suspend? How?

For example, I have an application who writes 'A' continually into a buffer whose start address is given by a device driver. Would it be possible that this application be notified that the system will suspend so that it could replace all this buffer with 'B' so that when driver is resumed, all what driver sees are 'B'?

Thanks a lot.

uestclx
  • 41
  • 4

2 Answers2

0

Been searching for the same thing. But unfortunately, I didn't find any user space notification during suspend/resume. Applications are just refrigerated/frozen and they will never know they are suspended.

However, one possible approach would be to add a generic netlink message sending or uevent from any driver's suspend/resume function that you can modify. Still the application may never get enough time to process it before it is frozen and might lead to race conditions. Say it received the suspend message and got frozen before it could process it. And once resumed, it will be processing the suspend message.

IMO, it is better to handle the scenario in the driver. Leave the user space alone.

subin
  • 490
  • 3
  • 13
  • Thanks a lot. I should've replied to you sooner xD. I had been searching for this for a long time, but didn't find anything. At last I came to a conclusion that applications will just frozen and know nothing about the suspension. – uestclx Aug 21 '17 at 03:14
0

I'm not sure whether it's useful for you in particular, given the mention of "embedded", however systemd can notify you over DBus: https://www.freedesktop.org/wiki/Software/systemd/inhibit/

Přemysl J.
  • 307
  • 4
  • 11