Real-time clock alarm

Real-time clock alarm

A real time clock alarm is a feature that can be used to allow a computer to 'wake up' after shut down to execute tasks every day or on a certain day. It can sometimes be found in the 'Power Management' section of a motherboard's BIOS setup. However, newer BIOS setups do not include an RTC alarm option, although it can still be set from within user applications. Wake On LAN, Wake on ring, and IPMI functions could also be used to start a computer after it is turned off.



In Android 4.0.1 and earlier release,
GoogleServicesFramework, GooglePartnerSetup, Maps setup Alarms via
AlarmManagerService of the type ELAPSED_REALTIME_WAKEUP and
RTC_WAKEUP.

com.google.android.partnersetup

com.google.android.apps.maps
com.google.android.gsf


首先搞清楚RTC在kernel内的作用: linux系统有两个时钟:一个是由主板电池驱动的“Real Time Clock”也叫做RTC或者叫CMOS时钟,硬件时钟。当操作系统关机的时候,用这个来记录时间,但是对于运行的系统是不用这个时间的。

  另一个时间是 “System clock”也叫内核时钟或者软件时钟,是由软件根据时间中断来进行计数的,

  内核时钟在系统关机的情况下是不存在的,所以,当操作系统启动的时候,内核时钟是要读取RTC时间

  来进行时间同步。并且在系统关机的时候将系统时间写回RTC中进行同步。 如前所述,Linux内核与RTC进行互操作的时机只有两个:

  1) 内核在启动时从RTC中读取启动时的时间与日期;

  2) 内核在需要时将时间与日期回写到RTC中。 系统启动时,内核通过读取RTC来初始化内核时钟,又叫墙上时间,该时间放在xtime变量中。

  The current time of day (the wall time) is defined in kernel/timer.c:

  struct timespec xtime;

  The timespec data structure is defined in <linux/time.h> as:struct timespec {

  time_t tv_sec; /* seconds */

  long tv_nsec; /* nanoseconds */

  };

  问题1:系统启动时在哪读取RTC的值并设置内核时钟进行时间同步的呢?

  最有可能读取RTC设置内核时钟的位置应该在arch/arm/kernel/time.c里的time_init函数内.time.c为系统的时钟驱动部分.time_init函数会在系统初始化时,由init/main.c里的start_kernel函数内调用.X86架构就是在这里读 RTC值并初始化系统时钟xtime的. ARM架构的time_init代码如下:/* arch/arm/kernel/time.c */void __init time_init(void)

  {

  if (system_timer->offset == NULL)

  system_timer->offset = dummy_gettimeoffset;

  system_timer->init();#ifdef CONFIG_NO_IDLE_HZ

  if (system_timer->dyn_tick)

  system_timer->dyn_tick->lock = SPIN_LOCK_UNLOCKED;

  #endif
  • 0
    点赞
  • 0
    收藏
    觉得还不错? 一键收藏
  • 0
    评论
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值