1.线程属性的初始化与销毁:
#include int pthread_attr_init(pthread_attr_t *attr);
int pthread_attr_destroy(pthread_attr_t *attr);
Both return: 0 if OK, error number on failure 2.设置线程属性--detackstate(分离状态):
#include int pthread_attr_getdetachstate(const pthread_attr_t *restrict attr, int *detachstate);
int pthread_attr_setdetachstate(pthread_attr_t *attr, int detachstate);
Both return: 0 if OK, error number on failure
detachstate有两个选项:PTHREAD_CREATE_DETACHED 分离状态启动线程
PTHREAD_CREATE_JOINABLE 正常状态启动线程 3.设置线程属性--stackaddr(线程栈的最低地址),stacksize(线程栈的大小):
#include int pthread_attr_getstack(const pthread_attr_t *restrict attr,
void **restrict stackaddr,
size_t *restrict stacksize);
int pthread_attr_setstack(const pthread_attr_t *attr,
void *stackaddr,
size_t *stacksize);
Both return: 0 if OK, error number on failure 4.设置线程属性--stacksize(线程栈的大小):
#include int pthread_attr_getstacksize(const pthread_attr_t *restrict attr,
size_t *restrict stacksize);
int pthread_attr_setstacksize(pthread_attr_t *attr,
size_t stacksize);
Both return: 0 if OK, error number on failure 5.设置线程属性--guardsize(线程栈末尾的警戒缓冲区大小)
#include int pthread_attr_getguardsize(const pthread_attr_t *restrict attr,
size_t *restrict guardsize);
int pthread_attr_setguardsize(pthread_attr_t *attr,
size_t guardsize);
Both return: 0 if OK, error number on failure 二.重点: