- r - 以节省内存的方式增长 data.frame
- ruby-on-rails - ruby/ruby on rails 内存泄漏检测
- android - 无法解析导入android.support.v7.app
- UNIX 域套接字与共享内存(映射文件)
我有一个任务链接到每 20 毫秒/50 赫兹执行一次的 Posix 定时器 (timer_create())。大多数情况下工作正常,除了每 334.5 秒(大约)定时器提前 10 毫秒执行一个周期。在接下来的 334.5 秒左右,间隔再次全部为 20 毫秒。
我已经包含了配置定时器的相关代码。该应用程序在 Gumstix 的默认 Linux 版本的 Gumstix Verdex Pro XL6P 上运行。我还使用 FIFO 调度算法对其进行了调度。
我的直觉告诉我这是一个整数溢出问题。也许还有其他东西使用相同的信号?我一直能够在董事会的执行和 session 中重现跳过。
这个问题不是问题,但我真的很想了解为什么会这样。
下面是配置定时器的代码:
//------------------------------------------------------------------------------
// Create a timer which fires at the specified time and calls a timer event
// handler.
//
// handler : function to be called when the timer expires
// us : number of microseconds to add to timer
// ms : number of milliseconds to add to timer
// sec : number of seconds to add to timer
//------------------------------------------------------------------------------
void createTimer(void (*handler)(void), uint32 us, uint32 ms, uint32 sec)
{
struct sigaction sigact;
struct sigevent sigev;
timer_t timerid;
struct itimerspec itval;
struct itimerspec oitval;
timer_info_t* newTimer = NULL;
// Initialize signalNum.
if (timers == NULL)
signalNum = SIGRTMAX;
if (signalNum < SIGRTMIN)
exitWithError("no avaiable signals, unable to create timers");
sigemptyset(&sigact.sa_mask);
sigact.sa_flags = SA_SIGINFO;
sigact.sa_sigaction = signalHandler;
// Set up sigaction to catch signal
if (sigaction(signalNum, &sigact, NULL) == -1)
exitWithError("sigaction() failed, unabled to creat timers");
// Create the POSIX timer to generate signo
sigev.sigev_notify = SIGEV_SIGNAL;
sigev.sigev_signo = signalNum;
sigev.sigev_value.sival_ptr = &timerid;
long ret = timer_create(CLOCK_REALTIME, &sigev, &timerid);
if (ret == 0)
{
// Prevent overflow in calculation of nsec below.
if (ms >= 1000)
{
sec += (ms / 1000);
ms = ms % 1000;
}
itval.it_value.tv_sec = sec;
itval.it_value.tv_nsec = (long)(us * 1000L) + (long)(ms * 1000L * 1000L);
// Configure it as a repeat timer.
itval.it_interval.tv_sec = itval.it_value.tv_sec;
itval.it_interval.tv_nsec = itval.it_value.tv_nsec;
if (timer_settime(timerid, 0, &itval, &oitval) != 0)
exitWithError("time_settime() error!");
}
else
exitWithError("timer_create() error!");
newTimer = (timer_info_t*)malloc(sizeof(timer_info_t));
newTimer->timer = timerid;
newTimer->handler = handler;
newTimer->sigNum = signalNum;
newTimer->next = NULL;
// Check to see if this is the first time through.
if (timers == NULL)
{
timers = newTimer;
atexit(deleteTimers);
}
else
lastTimer->next = newTimer;
lastTimer = newTimer;
signalNum--;
}
提前致谢。
最佳答案
我的猜测是您正在使用 ntp,并且它会以这些间隔调整时间。您可以尝试改用 CLOCK_MONOTONIC
,但根据 http://juliusdavies.ca/posix_clocks/clock_realtime_linux_faq.html它也可能受到影响。
关于c - Posix Timer 周期性地向前跳过其周期的一半,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/7276251/
我正在使用以下键存储哈希集:measurement: , f.e. measurement:1482236501103 ,然后在稍后我想传递某个时间戳并获取从给定时间戳到结束的所有记录。但由于 Red
有 Home.vue 和 Statistics.vue 页面。 Home.vue 渲染 TableFields.vue 组件。在 Home.vue 中,有一些字段编号,在页面加载时设置了初始值“3”。
Spring MVC ModelAndView forward 不工作。下面的代码没有将请求转发到 Name.jsp。非常感谢您的帮助。 package main.java.com.mkyong.co
我有一个这样的值列表, lst = [1, 2, 3, 4, 5, 6, 7, 8] 期望输出 : window size = 3 1 # first element in the list
我正在尝试将硬币类移动到按下键时的适当元素。但是,如果元素的名称相似,我不确定如何正确导航 DOM 树。另外,我根据按下键(e.which)向上/向下移动,但如果硬币在某些地方,我需要旋转回到顶部或底
我需要制作一个不循环的幻灯片,但实际上在幻灯片之间弹跳:例如,如果我有 3 张幻灯片,我希望幻灯片顺序为: 1 -> 2 -> 3 -> 2 -> 1 -> 2 ... 我想出了这个解决方案(使用 j
我只想获取下一次迭代中的元素(使用基于范围的 for 循环) 我试过类似的东西: *(&x+1) 应该表示“i+1”,如果“i”在这里是一个迭代器的话 bool factorChain(std::ve
我有一个 slider ,其可能值在 0 到 1 之间,步长为 0.1 例如,如果我在起点移动 slider ,动画将从 (0%) 开始,如果我将 slider 移动到 0.5 ( 50%) 表示将从
这个问题在这里已经有了答案: python time subtraction (1 个回答) 关闭 9 年前。 我想实现的很简单: time.time() 不太可读。如何获得: 例如 time.ti
如何在 html 中显示此 ► 播放(向前)或向右实心箭头符号? 最佳答案 是的,►,但它在所有浏览器中看起来可能不一样。 关于html - 如何在 html 中显示 ► 播放(向前)或向右实心箭头符
我正在开发 wpf c# 应用程序,我需要检测用户何时按下“/ ” 但我找不到“/ ” e.Key,我看到有Key.OemBackslash和类似的东西,但我找不到“/”(正斜杠)的正确事件.....
我有两个数据集,(dt1) 一个带有“开始”日期,每个 ID 最多两个条目(因为这些是 L 或 R 眼手术的条目)和一个 (dt2) 第二个数据库,其中包含多个日期之前和之后开始日期。这些不仅限于眼科
我有使用 3 个欧拉 Angular (aRotX、aRotY、aRotZ)在其位置(aX、aY、aZ)显示模型的代码: var m = mat4.create(); mat4.identity(m)
我需要从方向 vector (vForward) 获取旋转矩阵 我还有 vRight 和 vUp vector 。所有这些 vector 都是单位 vector 。 我只需要得到旋转矩阵。 要获得仅在
我是一名优秀的程序员,十分优秀!