eCos 系统下发现 pthread_cond_timedwait 超时失败,会立刻返回
pthread_cond_timedwait
根据 timeout 和 condition 阻塞线程
- 0: 正常情况,获取
condition - ETIMEDOUT: 超时
异常时设置超时会直接退出
time
This function returns the time since 00:00:00 UTC, January 1, 1970 (Unix timestamp) in seconds.
time() 在 eCos 下最终是调用栈如下
Cyg_WallClock::wallclock->get_current_time()get_hw_seconds()get_ds_hwclock()gx_rtc_time_read()
在此函数中强制转换出现问题,解决之后 pthread_cond_timedwait 正常
gettimeofday
可以得到更加精确的时间,精确到毫秒
gettimeofday() 定义在 ecos3.0/packages/compat/posix/v3_0/src/time.cxx,调用栈
cyg_current_time()Cyg_Clock::real_time_clock->current_value()