-2

When an android device enters sleep mode it is know that cpu sleeps. That means that, services, threads are paused and everything sleeps.

Is that true?

In case it is, what happens after the device is awaken? Threads continue from where they left off?

E.x if a thread reads from a database and device enters sleep mode(somehow). Afterwards the thread continue read the remaining records from DB?

  • Sharing your research helps everyone. Tell us what you've tried and why it didn’t meet your needs. This demonstrates that you’ve taken the time to try to help yourself, it saves us from reiterating obvious answers, and most of all it helps you get a more specific and relevant answer. Also see How to Ask – gnat Dec 16 '18 at 18:13
0

The operating system may interrupt or suspend a thread at any time. This is completely normal, e.g. to ensure that multiple threads can share one processor (pre-emptive scheduling). When a thread is scheduled to continue, the operating system will restore the thread's context, in particular: the virtual address space of the thread's memory, and any CPU registers. The thread cannot tell that it was suspended because it's exact state was restored, though of course time has passed in the meanwhile.

This process model is used by all Unix-family systems incl. Linux, and by extension also Android. For further info on the process model, you can read these lecture slides I found: http://www.cs.kent.edu/~farrell/osf03/oldnotes/L06.pdf

Before a device enters a suspended state, the operating system will suspend all running threads – but the details will depend on how that device suspension works (which components will be powered down).

  • Iam talking specifically about sleep mode. – Nick Dec 16 '18 at 18:23
  • @Nick I don't think Android has a clear sleep mode like a laptop would have, but a more sliding scale between maximum performance and minimum energy use. Suspending or killing unnecessary threads (e.g. apps when the screen is turned off) would be part of conserving energy. – amon Dec 16 '18 at 18:45
  • i would like to know what happens to a thread that reads from a database after is awaken from a sleep mode? I think is pretty specific what i ask. – Nick Dec 16 '18 at 19:34

Your Answer

By clicking "Post Your Answer", you acknowledge that you have read our updated terms of service, privacy policy and cookie policy, and that your continued use of the website is subject to these policies.

Not the answer you're looking for? Browse other questions tagged or ask your own question.