pthread快速参考
2014-02-08 12:53
274 查看
1,Pthread线程控制
int pthread_create(pthread_t *restrict tidp, const pthread_attr_t *restrict attr, void *(*stat_rtn)(void*), void *restrict arg);
int pthread_exit(void *status);
int pthread_cancel(pthread_t thread);
int pthread_join(pthread_t tid, void **tret);
int pthread_cleanup_push(void (*rtn)(void*), void *arg);
int pthread_clean_pop(int execute);
int pthread_equal(pthread_t tid1, pthread_t tid2);
pthread_t pthread_self(void);
2,Pthread提供多种同步机制:
1) Mutex(互斥量):pthread_mutex_xxx
2) Condition Variable(条件变量):pthread_con_xxx
3) Read/Write lock(读写锁):pthread_rwlock_xxx
4) Spin lock(自旋锁):pthread_spin_xxx
int pthread_mutex_init(pthread_mutex_t *restrict mutex, const pthread_mutexattr_t *restrict attr); // PTHREAD_MUTEX_INITIALIZER
int pthread_mutex_destroy(pthread_mutex_t *mutex);
int pthread_mutex_lock(pthread_mutex_t *mutex);
int pthread_mutex_trylock(pthread_mutex_t *mutex);
int pthread_mutex_unlock(pthread_mutex_t *mutex);
int pthread_rwlock_init(pthread_rwlock_t *restrict rwlock, const pthread_rwlockattr_t *restrict attr);
int pthread_rwlock_destroy(pthread_rwlock_t *rwlock);
int pthread_rwlock_rdlock(pthread_rwlock_t *rwlock);
int pthread_rwlock_wrlock(pthread_rwlock_t *rwlock);
int pthread_rwlock_tryrdlock(pthread_rwlock_t *rwlock);
int pthread_rwlock_trywrlock(pthread_rwlock_t *rwlock);
int pthread_rwlock_unlock(pthread_rwlock_t *rwlock);
int pthread_cond_init(pthread_cond_t *restrict cond, const pthread_condattr_t *restrict attr);
int pthread_cond_destroy(pthread_cond_t *cond);
int pthread_cond_wait(pthread_cond_t *restrict cond, pthread_mutex_t *restrict mutex);
int pthread_cond_timedwait(pthread_cond_t *restict cond, pthread_mutex_t *restrict mutex, const struct timespec *restrict abstime);
int pthread_cond_signal(pthread_cond_t *restrict cond);
int pthread_cond_broadcast(pthread_cond_t *restrict cond);
int pthread_spin_init(pthread_spinlock_t *lock, int pshared);
int pthread_spin_destroy(pthread_spinlock_t *lock);
int pthread_spin_lock(pthread_spinlock_t *lock);
int pthread_spin_trylock(pthread_spinlock_t *lock);
int pthread_create(pthread_t *restrict tidp, const pthread_attr_t *restrict attr, void *(*stat_rtn)(void*), void *restrict arg);
int pthread_exit(void *status);
int pthread_cancel(pthread_t thread);
int pthread_join(pthread_t tid, void **tret);
int pthread_cleanup_push(void (*rtn)(void*), void *arg);
int pthread_clean_pop(int execute);
int pthread_equal(pthread_t tid1, pthread_t tid2);
pthread_t pthread_self(void);
2,Pthread提供多种同步机制:
1) Mutex(互斥量):pthread_mutex_xxx
2) Condition Variable(条件变量):pthread_con_xxx
3) Read/Write lock(读写锁):pthread_rwlock_xxx
4) Spin lock(自旋锁):pthread_spin_xxx
int pthread_mutex_init(pthread_mutex_t *restrict mutex, const pthread_mutexattr_t *restrict attr); // PTHREAD_MUTEX_INITIALIZER
int pthread_mutex_destroy(pthread_mutex_t *mutex);
int pthread_mutex_lock(pthread_mutex_t *mutex);
int pthread_mutex_trylock(pthread_mutex_t *mutex);
int pthread_mutex_unlock(pthread_mutex_t *mutex);
int pthread_rwlock_init(pthread_rwlock_t *restrict rwlock, const pthread_rwlockattr_t *restrict attr);
int pthread_rwlock_destroy(pthread_rwlock_t *rwlock);
int pthread_rwlock_rdlock(pthread_rwlock_t *rwlock);
int pthread_rwlock_wrlock(pthread_rwlock_t *rwlock);
int pthread_rwlock_tryrdlock(pthread_rwlock_t *rwlock);
int pthread_rwlock_trywrlock(pthread_rwlock_t *rwlock);
int pthread_rwlock_unlock(pthread_rwlock_t *rwlock);
int pthread_cond_init(pthread_cond_t *restrict cond, const pthread_condattr_t *restrict attr);
int pthread_cond_destroy(pthread_cond_t *cond);
int pthread_cond_wait(pthread_cond_t *restrict cond, pthread_mutex_t *restrict mutex);
int pthread_cond_timedwait(pthread_cond_t *restict cond, pthread_mutex_t *restrict mutex, const struct timespec *restrict abstime);
int pthread_cond_signal(pthread_cond_t *restrict cond);
int pthread_cond_broadcast(pthread_cond_t *restrict cond);
int pthread_spin_init(pthread_spinlock_t *lock, int pshared);
int pthread_spin_destroy(pthread_spinlock_t *lock);
int pthread_spin_lock(pthread_spinlock_t *lock);
int pthread_spin_trylock(pthread_spinlock_t *lock);
相关文章推荐
- SED单行脚本快速参考(Unix 流编辑器)
- SED单行脚本快速参考 [转]
- 《SED 单行脚本快速参考》的 perl 实现
- SED单行脚本快速参考(Unix 流编辑器)
- Git快速参考手册
- Objective-C语法快速参考
- Windows 7库(Library):C#快速参考
- 12种设计模式的快速参考
- SED单行脚本快速参考
- SED单行脚本快速参考
- iPhone开发入门之Objective-C语法快速参考
- 正则表达式快速参考
- SED和AWK单行脚本快速参考
- LINUX shell快速参考
- SED单行脚本快速参考
- git命令快速参考
- 快速参考
- APT and Dpkg 快速参考表
- SED单行脚本快速参考(Unix 流编辑器)
- Bootstrap快速入门参考手册