关于reference-ril中的函数pthread_cond_timeout_np的解释
来源:互联网 发布:canon mp236 mac驱动 编辑:程序博客网 时间:2024/06/05 23:52
先贴出源代码:
int pthread_cond_timeout_np(pthread_cond_t *cond, pthread_mutex_t * mutex, unsigned msecs){ struct timespec ts; ts.tv_sec = msecs / 1000; ts.tv_nsec = (msecs % 1000) * 1000000; return __pthread_cond_timedwait_relative(cond, mutex, &ts);}
__pthread_cond_timedwait_relative的源代码:
int __pthread_cond_timedwait_relative(pthread_cond_t *cond, pthread_mutex_t * mutex, const struct timespec *reltime){ int status; int oldvalue = cond->value; pthread_mutex_unlock(mutex); status = __futex_wait(&cond->value, oldvalue, reltime); pthread_mutex_lock(mutex); if (status == (-ETIMEDOUT)) return ETIMEDOUT; return 0;}
在指定的时间间隔内阻塞
pthread_cond_reltimedwait_np(3C) 的用法与 pthread_cond_timedwait() 的用法基本相同,唯一的区别在于pthread_cond_reltimedwait_np() 会采用相对时间间隔而不是将来的绝对时间作为其最后一个参数的值。
pthread_cond_reltimedwait_np 语法
int pthread_cond_reltimedwait_np(pthread_cond_t *cv, pthread_mutex_t *mp, const struct timespec *reltime);
#include <pthread.h>#include <time.h>pthread_cond_t cv;pthread_mutex_t mp;timestruct_t reltime;int ret;/* wait on condition variable */ret = pthread_cond_reltimedwait_np(&cv, &mp, &reltime);
pthread_cond_reltimedwait_np() 每次返回时调用线程都会锁定并且拥有互斥锁,即使 pthread_cond_reltimedwait_np() 返回错误时也是如此。对于 Solaris 线程,请参见 cond_reltimedwait(3C)。pthread_cond_reltimedwait_np() 函数会一直阻塞,直到该条件获得信号,或者最后一个参数指定的时间间隔已过为止。
注 –
pthread_cond_reltimedwait_np() 也是取消点。
pthread_cond_reltimedwait_np 返回值
pthread_cond_reltimedwait_np() 在成功完成之后会返回零。其他任何返回值都表示出现了错误。如果出现以下任一情况,该函数将失败并返回对应的值。
EINVAL
描述:cv 或 reltime 指示的地址非法。
ETIMEDOUT
描述:reltime 指定的时间间隔已过。
- 关于reference-ril中的函数pthread_cond_timeout_np的解释
- MSDN关于RIL的翻译
- MSDN关于RIL的翻译
- MSDN关于RIL的翻译
- MSDN关于RIL的翻译
- 关于ril.java的胡说八道
- reference-ril.c解析
- reference-ril at指令
- Reference-RIL 运行框架
- 关于函数指针的解释
- 关于内联函数的解释
- RIL 函数
- RIL 机制---消息从RIL到reference-ril
- RIL 机制---消息从reference-ril到RIL
- 关于floor和ceil函数的解释
- 关于java中main函数的解释
- 关于函数名前加static的一些解释
- 关于simulink中的solver设置的解释
- 数据库 oracle for update of 和 for update区别【经典】
- 设计模式六大原则(2):里氏替换原则
- 五种JSP页面跳转方法详解
- 设置DataGridView控件的当前行,光标定位问题
- 虚继承和虚基类
- 关于reference-ril中的函数pthread_cond_timeout_np的解释
- usb 主设备号
- no ip redirects no ip unreachables no ip redirects
- Linux USB驱动框架分析
- 总结敏捷合作快速开发简单发布模式 .
- SQLite简单的入门操作
- 创建为ClickOnce清单签名的.pfx格式数字证书
- MFCGrid新加功能
- Hadoop常见问题及解决办法