apue 函数原型 ---线程

#include<pthread.h>

1.int pthread_equal(pthread_t tid1,pthread_t tid2);比较两个线程ID,若相等返回非0数值,否则返回0


2.pthread_t pthread_self();返回调用线程ID


3.int pthread_create(pthread_t *restrict tid,const pthread_attr_t *restrict attr,void* (*start_rtn((void*),void *restrict arg);若成功,返回0,否则返回错误编号


4.void pthread_exit(void *rval_ptr);

   int pthread_join(pthread_t thread,void ** rval_ptr);成功,返回0,否则返回错误编号


5.int pthread_cancel(pthread_t tid);成功返回0,否则返回错误编号


6.void pthread_cleanup_push(void (*rtn)(void *),void *arg);

   void pthread_cleanup_pop(int execute);


7.int pthread_detach(pthread_t tid);(分离线程);


8.int pthread_mutex_init(pthread_mutex_t *mutex,const phread_mutexattr_t *attr) 

   int pthread_mutex_destroy(pthread_mutex_t *mutex);


9.int pthread_mutex_lock(pthread_mutex_t *mutex);

   int phtead_mutex_unlock(pthread_mutex_t *mutex);

   int pthread_mutex_trylock(pthread_mutex_t *mutex);


10.int pthread_mutex_timedlock(pthread_mutex_t *mutex,const struct timespec *tsptr);


11.int pthread_rwlock_init(pthread_rwlock_t *rwlock,const pthread_rwlockattr_t *attr);

     int pthread_rwlock_destroy(pthread_rwlock_t *rwlock);


12.int pthread_rwlock_rdlock(phtread_rwlock_t *rwlock);

     int pthread_rwlock_wrlock(pthread_rwlock_t *rwlock);

     int pthread_rwlock_unlock(pthread_rwlock_t *rwlock);

     int pthread_rwlock_tryrdlock(pthread_rwlock_t *rwlock);

     int pthread_rwlock_trywrlock(pthread_rwlock_t *rwlock);

     int pthread_rwlock_timedrdlock(pthread_rwlock_t *rwlock,const struct timespec *tsptr);

     int phtread_rwlock_timedwrlock(......)


13,int pthread_cond_init(pthread_cond_t *cond,const pthread_condattr_t *attr);

     int pthread_const_destroy(pthread_cond_t *cond);

     int pthread_cond_wait(pthread_cond_t *cond,pthread_mutex_t *mut);

     int pthread_cond_timewait(pthread_cond_t *cond,pthread_mutex_t *mut,const struct timespec *tsptr);

     int pthread_cond_signal(pthread_cond_t *cond);

     int pthread_cond_broadcast(pthread_cond_t *cond);


14.int pthread_attr_init(pthread_attr_t *attr);

     int pthread_attr_destroy(pthread_attr_t *attr);


15.int pthread_attr_getdetachstate(const pthread_attr_t *attr,int *detachstate);

     int pthread_attr_setdetachstate(pthread_attr_t *attr,int *detachstate);


16.#include <signal.h>

int pthread_sigmask(int how,const sigset_t *set,sigset_t *oldset);

how取下列3个值之一:SIG_BLOCK,把信号集添加到线程信号屏蔽字中,SIG_SETMASK,用信号集替换线程的信号屏蔽字,SIG_UNBLOCK,从信号屏蔽字中移除信号集,当前信号屏蔽字存于oldset。


17.#include<signal.h>

int sigwait(const sigset_t *set,int *signop);

线程调用sigwait等待一个或者多个信号的出现(直到信号出现才运行),返回时,signop指向的整数包含发送的信号。


18.#include <signal.h>

int pthread_kill(pthread_t thread,int signo);向指定线程发送信号。


  • 0
    点赞
  • 0
    收藏
    觉得还不错? 一键收藏
  • 0
    评论

“相关推荐”对你有帮助么?

  • 非常没帮助
  • 没帮助
  • 一般
  • 有帮助
  • 非常有帮助
提交
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值