当前位置: 首页 > news >正文

上海seo课程seo整站优化报价

上海seo课程,seo整站优化报价,天津市建设教育培训中心的网站,设计网站faq需注意这里讲的是通过 pthread_create() 函数返回的线程 id,其实就是 glibc 库里维护的线程id,它跟内核维护的线程 id 不一样,pthread_create() 返回的线程 id 并不一定是唯一的。我们看 pthread_create 函数的源码,它最后返回的线程 id…

        这里讲的是通过 pthread_create() 函数返回的线程 id,其实就是 glibc 库里维护的线程id,它跟内核维护的线程 id 不一样,pthread_create() 返回的线程 id 并不一定是唯一的。我们看 pthread_create 函数的源码,它最后返回的线程 id 是什么样的?

      //.............................../* Check for valid priorities.  */int minprio = INTERNAL_SYSCALL (sched_get_priority_min, scerr, 1,iattr->schedpolicy);int maxprio = INTERNAL_SYSCALL (sched_get_priority_max, scerr, 1,iattr->schedpolicy);if (pd->schedparam.sched_priority < minprio|| pd->schedparam.sched_priority > maxprio){/* Perhaps a thread wants to change the IDs and if waitingfor this stillborn thread.  */if (__builtin_expect (atomic_exchange_acq (&pd->setxid_futex, 0)== -2, 0))lll_futex_wake (&pd->setxid_futex, 1, LLL_PRIVATE);__deallocate_stack (pd);return EINVAL;}}/* Pass the descriptor to the caller.  */*newthread = (pthread_t) pd;LIBC_PROBE (pthread_create, 4, newthread, attr, start_routine, arg);/* Start the thread.  */return create_thread (pd, iattr, STACK_VARIABLES_ARGS);
}

函数就是通过参数 newthread 返回的线程 id,实现里直接把 pd 强转成 pthread_t 类型赋值给了 newthread。这个 pd 是什么类型呢?

int
__pthread_create_2_1 (newthread, attr, start_routine, arg)pthread_t *newthread;const pthread_attr_t *attr;void *(*start_routine) (void *);void *arg;
{STACK_VARIABLES;const struct pthread_attr *iattr = (struct pthread_attr *) attr;if (iattr == NULL)/* Is this the best idea?  On NUMA machines this could meanaccessing far-away memory.  */iattr = &default_attr;struct pthread *pd = NULL;int err = ALLOCATE_STACK (iattr, &pd);if (__builtin_expect (err != 0, 0))/* Something went wrong.  Maybe a parameter of the attributes isinvalid or we could not allocate memory.  Note we have totranslate error codes.  */return err == ENOMEM ? EAGAIN : err;

struct pthread 是一个结构体,记录线程信息的:

所以这个线程 id 就是一个地址(被强转成pthread_t,也就是 unsigned long int 类型值)值?用 GDB 看一下最清楚了:

这个 pd 指针的值就是 0x7ffff7fd8700,而这个值也是结构体里数据的首地址:

 

所以这个地址值转成 unsignd long int 是多少呢?强转后的十进制值就是 140737353975552。

 

 

就是执行程序里打印的线程 id。 所以 pthread_create() 返回的线程 id,其实就是保存线程信息的结构体的首地址。因此这个线程 id 是很重要的,其他线程相关函数可以通过这个 id 访问线程信息,如 pthread_t 强转为 struct pthread* 类型,其实 thread_id 就是一个地址:

int
pthread_getattr_np (thread_id, attr)pthread_t thread_id;pthread_attr_t *attr;
{struct pthread *thread = (struct pthread *) thread_id;struct pthread_attr *iattr = (struct pthread_attr *) attr;int ret = 0;lll_lock (thread->lock, LLL_PRIVATE);/* The thread library is responsible for keeping the values in thethread desriptor up-to-date in case the user changes them.  */memcpy (&iattr->schedparam, &thread->schedparam,sizeof (struct sched_param));iattr->schedpolicy = thread->schedpolicy;/* Clear the flags work.  */iattr->flags = thread->flags;/* The thread might be detached by now.  */if (IS_DETACHED (thread))iattr->flags |= ATTR_FLAG_DETACHSTATE;/* This is the guardsize after adjusting it.  */iattr->guardsize = thread->reported_guardsize;

这个函数就是获取指定线程的信息,其中当然包括用户设置的栈大小

所以要获取线程栈大小,需要使用两个函数调用:

 pthread_getattr_np(pthread_self(), &attr)

pthread_attr_getstacksize(&attr, &stack_size) 

http://www.yidumall.com/news/86376.html

相关文章:

  • 做网站用到的软件成都网站seo诊断
  • 服务商标是什么意思上海搜索排名优化公司
  • 运动服饰网站建设目的seo课程培训机构
  • django做的购物网站今天新闻头条最新消息
  • 建设网站要点找百度
  • 工程项目管理咨询公司加盟app关键词排名优化
  • 天津做企业网站东营seo网站推广
  • 寺院的网站怎么做软文营销写作技巧
  • 烟台装修公司网站建设企业信息查询
  • 网站如何做域名解析重庆seo扣费
  • 社交网站开发注意事项宁德市教育局
  • 营销网站建设平台新东方一对一辅导价格
  • 网站制作费可以做业务宣传费网络营销的方式和手段
  • 办公空间设计装修安卓优化大师下载
  • qq推广引流怎么做南昌seo方案
  • 推荐的网站b站推广平台
  • 自己做网站系统域名注册商怎么查
  • 做宠物店网站的素材免费宣传平台
  • 做国际网站每年要多少钱站长之家站长工具
  • 帮做装修设计的网站站内seo内容优化包括
  • 淘宝客不建网站怎样做近期的新闻热点
  • 品牌网站建设怎么收费提高百度搜索排名工具
  • 湖南网站建设开发山东省住房和城乡建设厅
  • 国内免费代理ip地址和端口长沙seo招聘
  • 网站建设家乡网页设计模板关键词规划师工具
  • 网站推广分销系统惠州百度推广优化排名
  • 网站模板视频教程纯注册app拉新平台
  • wordpress控制上下页链接优化大师官方
  • 阿克苏网站建设有广告位怎么找广告商
  • 网站描文本链接怎么做互动营销策略