Android Kernel autonomous wake-up system Method--Set alarm

Source: Internet
Author: User

We know that alarm is usually the upper set, the kernel driver inside will set time to write alarm register, the arrival of trigger, but kernel inside can also set alarm,

In particular, when the system drives the need do something during hibernation, the alarm interrupts the wake-up system when the alarm is set before bedtime.

Before writing a alarm article, and then want to mention the Android kernel to wake up the system is usually the interrupt registration as the wake-up source, the system is awakened by the interrupt signal. Add wake lock at the same time in interrupt processing

mechanism to prevent the system from hibernating until Wake Lock is released when the task is completed.


#include <linux/android_alarm.h>

1: Define the alarm variable:
struct alarm xx_alarm;

2:alarm bindings:
Alarm Trigger when callback:
static void
Xx_callback (struct alarm *alarm)
{
Structchip *chip = container_of (Alarm, Structchip,
Xx_alarm);


Schedule_work (&chip->xx_work);
}

Alarm_init (&chip->xx_alarm, Android_alarm_rtc_wakeup,
Xx_callback);

3: Set time, dispatch alarm wake-up system:

struct TIMESPEC ts;
Getnstimeofday (&ts);
Ts.tv_sec + = Time_triger;
Alarm_start_range (&chip->xx_alarm,
Timespec_to_ktime (TS),

Timespec_to_ktime (TS));


Android Kernel autonomous wake-up system Method--Set alarm

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.