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