RTAI的用户空间编程(三)——定期运行一个任务

10 篇文章 9 订阅

1. 函数
在这个阶段,计时器根据定时器政策选择(单触发vs周期)以适当的周期运行,它允许设置一个实时任务定期调度。这可以用以下API实现:

int rt_task_make_periodic (RT_TASK *task, RTIME start_time, RTTIME period);
int rt_task_make_periodic (RT_TASK *task, RTIME start_delay, RTTIME period);

2.参数
task:任务指针,之前由rt_task_init()创建的,当rt_task_wait_period()被调用时,以period为周期执行。
start_time:第一次执行时间,是一个以clock ticks测量的绝对值。
start_delay:第一次执行时间,相对于当前时间,以纳秒测量。
period:任务循环周期。

3. 注意

  • 为了更方便的处理clock ticks和纳秒,在rtai_sched.h中有两个宏定义能帮助你,RTIME count2nano(RTIME timercounts);RTIME nano2count (RTIME nanosecs),它们只转换时间单位,但是你要记住,计数单位与选择的时间模式(单触发/周期)相关。
  • Recall that the term clock ticks depends on the mode in which the hard timer runs. So if the hard timer was set as periodic a clock tick will last as the period set in start_rt_timer,while if oneshot mode is used a clock tick will last as the inverse of the runningfrequency of the hard timer in use and irrespective of any period used in the call tostart_rt_timer.
  • 0
    点赞
  • 1
    收藏
    觉得还不错? 一键收藏
  • 0
    评论
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

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

抵扣说明:

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

余额充值