如何查看有那些多线程系统调用属性api
线程属性系统api举例
/*
int pthead_attr_init(pthread_attr_t *attr); -对属性变量初始化int pthread_attr_destroy(pthread_attr_t *attr); -使用完毕需要销毁int pthread_attr_getdetachstate(const pthread_attr_t *attr, int*detachstate); -获取线程分离的属性int pthread_attr_setdetachstate (pthread_attr_t *attr, intdetachstate);-给属性设置一些值,设置线程分离的属性*/
#include <pthread.h>
#include <stdio.h>
#include <string.h>
void *thread_cal(void *arg)
{printf("子线程id=%ld.收到数据%s:\n",pthread_self(),(char *)arg);return NULL;
}
int main()
{//创建一个线程属性变量pthread_attr_t attr;pthread_attr_init(&attr);//设置属性pthread_attr_setdetachstate(&attr,PTHREAD_CREATE_DETACHED);pthread_t tid;//获取线程zhan大小size_t size;pthread_attr_getstacksize(&attr,&size);printf("pthread stack size: %ld\n",size);int ret = pthread_create(&tid,&attr,thread_cal,NULL);if(ret != 0){char *error_s = strerror(ret);printf("pthread_create error:%s\n",error_s);}printf("主线程id:%ld,子线程id:%ld\n",pthread_self(), tid);//释放线程属性资源pthread_attr_destroy(&attr);pthread_exit(NULL);//主线程退出return 0;
}