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

响应式网站的概念北京网站制作net2006

响应式网站的概念,北京网站制作net2006,动漫网页模板,在线p图这里讲的是通过 pthread_create() 函数返回的线程 id#xff0c;其实就是 glibc 库里维护的线程id#xff0c;它跟内核维护的线程 id 不一样#xff0c;pthread_create() 返回的线程 id 并不一定是唯一的。我们看 pthread_create 函数的源码#xff0c;它最后返回的线程 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.hkea.cn/news/14301818/

相关文章:

  • 广州建设水务局网站wordpress注册函数
  • wordpress 网站做外贸网络推广网站
  • 吉安网站建设wordpress模板不一样
  • 找工作哪个网站好智联招聘做网站引流
  • 电商平台正在建设中网站页面提示网站维护的要求包括哪些
  • 通栏式网站wordpress获取文章浏览次数
  • 青海企业网站制作能制作视频的软件
  • 网站服务器怎么查询滨海做网站
  • 网页设计入门代码兰州搜索引擎优化
  • 做任务给佣金的网站有哪些网站建设服务合同
  • 一站式网站建设用途微信公众号如何创建视频链接
  • 网站的域名可以修改吗jquery素材网站
  • 青岛哪里有做网站公司的mvc个人网站怎么做
  • 杭州便宜的手机网站建设wordpress仿堆糖
  • 网站建设会销互联网之光博览会预约
  • 网站有了如何做推广环保网站主题
  • 北京礼品网站建设新手怎么学做电商
  • 乾安网站建设哪家好全球跨境电商平台排行榜前十名
  • 巩义建设网站怎样写网站描述
  • 豆芽网站建设 优帮云昌平知名的网站制作建设报价
  • 网站备案前置审批文件wordpress还是hexo
  • 手机免费建站app做漫画的网站有哪些
  • 做网站已经不行0成本无货源开网店
  • 浙江电商网站建设销售网站做我女朋友
  • python自学网站南宁 网站建设
  • 网站建设与网页设计课程设计西安网站建设推广服务
  • 肥城移动网站制作自己可以设计装修的软件
  • 24小时学会网站建设pdf工信部备案查询企业名单
  • 建筑图集网站erp沙盘模拟实训报告
  • 四川省建设厅网站投诉淘宝宝贝关键词排名查询工具