Part Number:AM4379
问题:
你好,在PC Ubuntu上运行posix定时器测试程序是正常的可以进入到线程,但在437x平台上运行时却只能进入一次线程,请问这可能是什么原因导致的呢?代码及运行结果见下图:
timer1.c
#include <stdio.h> #include <signal.h> #include <time.h> #include <string.h> #include <stdlib.h> #include <unistd.h> void timer_thread(union sigval v) {printf("timer[CLOCK_MONOTONIC] function! %d\n", v.sival_int); } int main() {timer_t timerid;struct sigevent evp;memset(&evp, 0, sizeof(struct sigevent));//清零初始化evp.sigev_value.sival_int = 111;//也是标识定时器的,回调函数可以获得evp.sigev_notify = SIGEV_THREAD;//线程通知的方式,派驻新线程evp.sigev_notify_function = timer_thread;//线程函数地址if (timer_create(CLOCK_MONOTONIC, &evp, &timerid) == -1){perror("fail to timer_create");exit(-1);}/* 第一次间隔it.it_value这么长,以后每次都是it.it_interval这么长,就是说it.it_value变0的时候会>装载it.it_interval的值 */struct itimerspec it;it.it_interval.tv_sec = 1; // 回调函数执行频率为1s运行1次it.it_interval.tv_nsec = 0;it.it_value.tv_sec = 1;// 倒计时3秒开始调用回调函数it.it_value.tv_nsec = 0;if (timer_settime(timerid, 0, &it, NULL) == -1){perror("fail to timer_settime");exit(-1);}//pause();while (1);return 0; }
Shine:
我把您的问题升级到e2e给产品线工程师,请关注下面帖子的回复。https://e2e.ti.com/support/processors-group/processors/f/processors-forum/1079575/am4379-posix-timer-can-run-only-one-time-on-am4379