当前位置: 技术问答>linux和unix
嵌入式平台上调用settimeofday()函数导致死机的问题
来源: 互联网 发布时间:2016-05-07
本文导语: time_t stTime = mktime(&stTM); printf("+++++++++++++++%d+++++++++n", stTime); tv.tv_sec = stTime; tv.tv_usec = 0; tz.tz_minuteswest = 0; tz.tz_dsttime = 0; if (0 ...
time_t stTime = mktime(&stTM);
printf("+++++++++++++++%d+++++++++n", stTime);
tv.tv_sec = stTime;
tv.tv_usec = 0;
tz.tz_minuteswest = 0;
tz.tz_dsttime = 0;
if (0 != settimeofday ( &tv, &tz))
{
LOG_E((__FILE__, __LINE__, "Other", "setSystemClockEnd", "Set system clock error!"));
}
else
{
printf("+++++++++++++++++++++SUCCESS+++++++++++++++n");
}
我直接通过mktime得到秒数,然后设置进去,但是很多时候运行会发生异常,提示信息如下
WARNING: at kernel/time/clockevents.c:82 clockevents_program_event()
[] (dump_stack+0x0/0x14) from [] (clockevents_program_event+0x4c/0x150)
[] (clockevents_program_event+0x0/0x150) from [] (tick_program_event+0x4c/0xc4)
r8:00000000 r7:fff6560d r6:201e1d08 r5:000000d2 r4:2020c11f
[] (tick_program_event+0x0/0xc4) from [] (hrtimer_force_reprogram+0xa8/0xac)
[] (hrtimer_force_reprogram+0x0/0xac) from [] (retrigger_next_event+0x84/0x98)
r4:00000000
[] (retrigger_next_event+0x0/0x98) from [] (clock_was_set+0x20/0x30)
r7:00000000 r6:0018fd2a r5:5bb8e708 r4:b755aa38
[] (clock_was_set+0x0/0x30) from [] (do_settimeofday+0xfc/0x11c)
[] (do_settimeofday+0x0/0x11c) from [] (do_sys_settimeofday+0xf4/0x120)
[] (do_sys_settimeofday+0x0/0x120) from [] (sys_settimeofday+0xd8/0xe8)
r6:00008ea4 r5:becfe9ec r4:becfe9e4
[] (sys_settimeofday+0x0/0xe8) from [] (ret_fast_syscall+0x0/0x2c)
r5:00000000 r4:00017008
请问是为什么呢,stTime可以确定是有值的。谢谢!
printf("+++++++++++++++%d+++++++++n", stTime);
tv.tv_sec = stTime;
tv.tv_usec = 0;
tz.tz_minuteswest = 0;
tz.tz_dsttime = 0;
if (0 != settimeofday ( &tv, &tz))
{
LOG_E((__FILE__, __LINE__, "Other", "setSystemClockEnd", "Set system clock error!"));
}
else
{
printf("+++++++++++++++++++++SUCCESS+++++++++++++++n");
}
我直接通过mktime得到秒数,然后设置进去,但是很多时候运行会发生异常,提示信息如下
WARNING: at kernel/time/clockevents.c:82 clockevents_program_event()
[] (dump_stack+0x0/0x14) from [] (clockevents_program_event+0x4c/0x150)
[] (clockevents_program_event+0x0/0x150) from [] (tick_program_event+0x4c/0xc4)
r8:00000000 r7:fff6560d r6:201e1d08 r5:000000d2 r4:2020c11f
[] (tick_program_event+0x0/0xc4) from [] (hrtimer_force_reprogram+0xa8/0xac)
[] (hrtimer_force_reprogram+0x0/0xac) from [] (retrigger_next_event+0x84/0x98)
r4:00000000
[] (retrigger_next_event+0x0/0x98) from [] (clock_was_set+0x20/0x30)
r7:00000000 r6:0018fd2a r5:5bb8e708 r4:b755aa38
[] (clock_was_set+0x0/0x30) from [] (do_settimeofday+0xfc/0x11c)
[] (do_settimeofday+0x0/0x11c) from [] (do_sys_settimeofday+0xf4/0x120)
[] (do_sys_settimeofday+0x0/0x120) from [] (sys_settimeofday+0xd8/0xe8)
r6:00008ea4 r5:becfe9ec r4:becfe9e4
[] (sys_settimeofday+0x0/0xe8) from [] (ret_fast_syscall+0x0/0x2c)
r5:00000000 r4:00017008
请问是为什么呢,stTime可以确定是有值的。谢谢!
|
stTime
是多少的呢?
用time(NULL)代替mktime不行么?
是多少的呢?
用time(NULL)代替mktime不行么?
|
tv, tz是在哪里定义的?第二个参数传NULL试试
|
两个都设为NULL试试?
您可能感兴趣的文章:
本站(WWW.)旨在分享和传播互联网科技相关的资讯和技术,将尽最大努力为读者提供更好的信息聚合和浏览方式。
本站(WWW.)站内文章除注明原创外,均为转载、整理或搜集自网络。欢迎任何形式的转载,转载请注明出处。
本站(WWW.)站内文章除注明原创外,均为转载、整理或搜集自网络。欢迎任何形式的转载,转载请注明出处。