Contiki-Timer 概述

Contiki有一个clock模块和一系列timer模块:timerstimerctimeretimer,和rtimer

一、clock模块

clock模块提供一些处理系统时间的函数,还有一些用来阻塞CPU的函数。

timer模块的实现以clock模块为基础。

二、timer和stimer模块

timer和stimer提供最简单的形式来判断一段时间是否到期。

timer使用clock tick来判断。

stimer使用秒来判断,可以判断更长的时间间隔。

timer和stimer可以使用在中断中

三、etimer模块

etimer用于在一段时间后向Contiki processes发送event

etimer可使Contiki processes在等待一段时间的同时,可以继续做其他的工作,或者进入低功耗模式。

四、ctimer模块

ctimer提供回调timer,可以在一段时间后调用回调函数。

向etimer模块一样,ctimer使系统在等待一段时间的同时,可以继续工作,或者进入低功耗模式。

因为ctimer是调用回调函数,这在一些没有和特定进程相关联的代码中特别有用,特别是协议的实现,Rimer协议栈使用callback timer来处理通信超时。

五、rtimer模块

rtimer用于处理实时任务。

The rtimer library pre-empt any running Contiki process in order to let the real-time tasks execute at the scheduled time. The real-time tasks are used in time critical code such as the X-MAC implementation where the radio needs to be turned on or off at scheduled times without delay.

 

参考资料:https://github.com/contiki-os/contiki/wiki/Timers#The_Contiki_Timer_Modules

posted @ 2016-10-12 10:22  我是老邱  阅读(1273)  评论(0编辑  收藏  举报