锐英源软件
第一信赖

精通

英语

开源

擅长

开发

培训

胸怀四海 

第一信赖

当前位置:锐英源 / 英语翻译 / POSIX定时器
服务方向
人工智能数据处理
人工智能培训
kaldi数据准备
小语种语音识别
语音识别标注
语音识别系统
语音识别转文字
kaldi开发技术服务
软件开发
运动控制卡上位机
机械加工软件
软件开发培训
Java 安卓移动开发
VC++
C#软件
汇编和破解
驱动开发
联系方式
固话:0371-63888850
手机:138-0381-0136
Q Q:396806883
微信:ryysoft

锐英源精品开源心得,转载请注明:“锐英源www.wisestudy.cn,孙老师作品,电话13803810136。需要全文内容也请联系孙老师。

POSIX定时器

Descritpion 描述

POSIX timers provides mechanisms to notify a thread when the time (measured by a particular clock) has reached a specified value, or when a specified amount of time has passed.

POSIX定时器提供机制来通知,向线程通知时间(由特定时钟测定)达到指定的值,或指定时间已经过去。

Although RTLinux has good and accurate timing facilities, it do not provides general timer functionality. RTLinux defines only one timer for each thread, which is used to implement the periodic behaviour of the thread. 虽然RTLinux具有良好的和精确的计时设施,但它不提供定时器功能。RTLinux定义为每个线程只有一个定时器,用于实现线程的周期性行为。

This component implements the POSIX real-time extensions. 这个组件实现了POSIX实时扩展。

Layer 层

An efficient implementation of the timers has to be done at the lowest kernel level, therefore this component is located at the Low-Level RTLinux layer. It deeply depends on the scheduler and signal code. 计时器的有效实现必须在内核级别最低,因此该组件位于低级RTLinux层。它深深地依赖于调度器和信号代码。

API / Compatibility API /兼容性

This component provides all the functionalities described by the POSIX standard, but the one related to real-time signals, because the signals component does not provide it.

此组件提供POSIX标准描述的所有功能,除了一个相关的实时信号以外,因为组件并没有提供它的信号。

int timer_create(clockid_t clockid, struct sigevent
*restrict evp, timer_t *restrict timer_id);
int timer_delete(timer_t *timer_id);
int timer_settime(timer_t timer_id, int flags,
const struct itimerspec *new_setting,
struct itimerspec *old_setting);
int timer_gettime(timer_t timer_id, struct itimerspec *expires);
int timer_getoverrun(timer_t timer_id);

Timers implementation supports both CLOCK_MONOTONIC and CLOCK_real-time. 同时支持CLOCK_MONOTONIC和CLOCK_real-time计时器实现。

Implementation issues 实现问题

In RTLinux timer_t type is implemented as a pointer to the timer_struct. When a timer is created, the memory required to store the timer_struct is dynamically allocated. For this reason, timer_create() can only be called while in Linux space, that is, all timers must be created in the init_module(). For the same reason, timers can only be deleted in cleaun_module(). This implementation follows the general style of RTLinux used in mutex, semaphores, threads, etc; all data is preallocated before the threads are started.

在RTLinux内timer_t 类型是作为一个timer_struct指针实现的。当创建一个定时器,用于存储时间结构所需的存储器是动态分配的。出于这个原因,timer_create()只能在Linux的空间,也就是说,必须在init_module()创建计时器。出于同样的原因,计时器只在cleaun_module被删除()。这个实现遵循综合的形式,RTLinux用于互斥,信号量、线程等,所有的数据在线程启动之前都要预先分配。

Timers are stored in a linked list sorted by thread owner priority, which speeds-up the code that finds the next timer to expire. 计时器都存储在一个按线程拥有优先级排序排列的链表上,加速向上即找到下一个计时器到期的代码。。

Note: during the implementation two bugs were found in the RTLinux code, on functions usleep() and timespec_add_ns(). 注:实施过程中在Linux代码中发现了两个错误:usleep()函数和timespec_add_ns()函数。

Validation criteria 验证标准

As in the case of signals component, increases RTLinux POSIX compatibility and reduces the cost of porting applications to Rtlinux. 在信号分量的情况下,,增加RTLinux POSIX兼容性,降低将应用程序移植到Rtlinux的成本。

Allows to implement watchdog timers. 允许实现监视时钟定时器。

The timers overhead is negligible when no timer is armed. When several timers are armed, the overhead introduced is O(n) where n is the number of armed timers. Due to the flexibility and changing scenarios (priority inheritance, scheduler operational modes, different scheduling policies, etc.) it is not possible to use advanced data structures to achieve better worst case overhead. It is possible to use some heuristics to improve the response time in some cases, but the worst case remains the same.

当没有定时布防后,该定时器的开销可以忽略不计。当几个定时器打开,引入的开销是O(n),n是打开计时器的数量。由于灵活性和变化方案(优先级继承,调度器操作模式,不同的调度策略等)这是不可能利用高级数据结构,以达到更好的最坏情况下的开销。也可以使用一些启发式,以改善在某些情况下,响应时间,但最坏的情况是相同的。

友情链接
版权所有 Copyright(c)2004-2021 锐英源软件
公司注册号:410105000449586 豫ICP备08007559号 最佳分辨率 1024*768
地址:郑州大学北校区院(文化路97号院)内