Underlying understanding of android alarm

Source: Internet
Author: User

Share the summary about alarm when debugging the alarm Shutdown alarm;

Upper-layer calls of alarm include RTC wake-up and alarm alarms. The former is used more frequently and the interfaces are the same. frequent calls of upper-layer applications to rtc wake-up systems increase power consumption, some manufacturers have implemented the so-called synchronous heartbeat technology to uniformly plan the RTC wake-up system;

In essence, alarm starts timer at the underlying layer. When the system is not sleep, timer triggers the trigger and calls the alarm callback function to change global variables.
Enable the ioctl ANDROID_ALARM_WAIT initiated by the upper layer to return a successful result. If the return fails, the ioctl wait will be continuously returned. When the system is sleeping, the current alarm timer is set to the end.
The RTC register plays a role. A few seconds before the timer trigger triggers an RTC interrupt and serves as the interrupt source to wake up the system. After the wake-up, timer counts the sleep time into the on-time alarm. The same applies to the Shutdown Alarm,
The trigger of the alarm trigger is triggered by RTC interruption to enable the alarm on time;


Timer initialization:



Alarm callback function:


Ioctl wait: // wae_up must be waited for when the trigger is triggered; otherwise, the process remains asleep;



RTC wake up the underlying LOG:


Time written to the RTC register:

ALARM timer trigger time:

Related Article

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.