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

华侨城网站建设用ps怎么做网站背景

华侨城网站建设,用ps怎么做网站背景,湖南省建设厅厅长鹿山,天津响应式网页建设公司看到很多程序都是根据CPU个数来创建线程个数#xff0c;当时很不理解他们之间的关系#xff0c;请教了项目组的同事后才有了大致了解。1. 相关系统函数下面的函数可以通过man命令查询到。SYNOPSIS#define _GNU_SOURCE#include int pthread_setaffinity_np(pthread_t thread, …看到很多程序都是根据CPU个数来创建线程个数当时很不理解他们之间的关系请教了项目组的同事后才有了大致了解。1. 相关系统函数下面的函数可以通过man命令查询到。SYNOPSIS#define _GNU_SOURCE#include int pthread_setaffinity_np(pthread_t thread, size_t cpusetsize,const cpu_set_t *cpuset);int pthread_getaffinity_np(pthread_t thread, size_t cpusetsize,cpu_set_t *cpuset);Compile and link with -pthread.DESCRIPTIONThe pthread_setaffinity_np() sets the CPU affinity mask of the thread thread to the CPU set pointed to by cpuset. If the call is successful, and the thread isnot currently running on one of the CPUs in cpuset, then it is migrated to one of those CPUs.The pthread_getaffinity_np() function returns the CPU affinity mask of the thread thread in the buffer pointed to by cpuset.For more details on CPU affinity masks, see sched_setaffinity(2). For a description of a set of macros that can be used to manipulate and inspect CPU sets, seeCPU_SET(3).The argument cpusetsize is the length (in bytes) of the buffer pointed to by cpuset. Typically, this argument would be specified as sizeof(cpu_set_t). (It maybe some other value, if using the macros described in CPU_SET(3) for dynamically allocating a CPU set.)RETURN VALUEOn success, these functions return 0; on error, they return a non-zero error number.简而言之这两个函数一个设置在哪个CPU核上运行另一个获取设置的参数(mask),既可以查询出当前进程在运行在哪个核上CPU_ZERO() Clears set, so that it contains no CPUs.设置为空没有任何CPUCPU_SET() Add CPU cpu to set.将某个核加入CPU集合CPU_CLR() Remove CPU cpu from set.将某个核清理出CPU集合CPU_ISSET() Test to see if CPU cpu is a member of set.判断某个核是否在CPU集合中设置。cpu集合可以认为是一个掩码每个设置的位都对应一个可以合法调度的 cpu而未设置的位则对应一个不可调度的 CPU。换而言之线程都被绑定了只能在那些对应位被设置了的处理器上运行。通常掩码中的所有位都被置位了也就是可以在所有的cpu中调度。CPU_COUNT() Return the number of CPUs in set.2.下面是我的测试代码。测试环境系统 SUSE 10linux 内核版本2.6.32.12CPU 8核2.1  根据CPU核个数创建线程并绑定void *myfunWithMultiThread(void *arg){cpu_set_t mask;cpu_set_t get;int i 0;int num 0;int cpuID *(int *)arg;CPU_ZERO(mask);CPU_SET(cpuID, mask);if (pthread_setaffinity_np(pthread_self(), sizeof(mask), mask) 0) {fprintf(stderr, set thread affinity failed\n);}CPU_ZERO(get);if (pthread_getaffinity_np(pthread_self(), sizeof(get), get) 0) {fprintf(stderr, get thread affinity failed\n);}num sysconf(_SC_NPROCESSORS_CONF);for (i 0; i num; i) {if (CPU_ISSET(i, get)) {printf(thread %d is running in processor %d\n, (int)pthread_self(), i);printf(Original setting is in processor %d\n\n, cpuID);}}sleep(10);}int main(int argc, char *argv[]){pthread_t tid;int num 0;int i 0;num sysconf(_SC_NPROCESSORS_CONF);int id[16];printf(System has %d processor(s),so create %d threads\n, num,num);for(i 0; i num; i){id[i] i;if (pthread_create(tid, NULL, (void *)myfunWithMultiThread, (void *)id[i]) ! 0){fprintf(stderr, thread create failed\n);return -1;}}pthread_join(tid, NULL);return 0;}运行结果System has 8 processor(s),so create 8 threadsthread 1188759312 is running in processor 5Original setting is in processor 5thread 1205544720 is running in processor 3Original setting is in processor 3thread 1197152016 is running in processor 4Original setting is in processor 4thread 1230722832 is running in processor 0Original setting is in processor 0thread 1213937424 is running in processor 2Original setting is in processor 2thread 1222330128 is running in processor 1Original setting is in processor 1thread 1180366608 is running in processor 6Original setting is in processor 6thread 1171973904 is running in processor 7Original setting is in processor 72.2 不绑定测试代码System has 8 processor(s),so create 8 threadsthread -196520176 is running in processor 0thread -196520176 is running in processor 1thread -196520176 is running in processor 2thread -196520176 is running in processor 3thread -196520176 is running in processor 4thread -196520176 is running in processor 5thread -196520176 is running in processor 6thread -196520176 is running in processor 7thread -221698288 is running in processor 0thread -221698288 is running in processor 1thread -221698288 is running in processor 2thread -221698288 is running in processor 3thread -221698288 is running in processor 4thread -221698288 is running in processor 5thread -221698288 is running in processor 6thread -221698288 is running in processor 7thread -213305584 is running in processor 0thread -213305584 is running in processor 1thread -213305584 is running in processor 2thread -213305584 is running in processor 3thread -213305584 is running in processor 4thread -213305584 is running in processor 5thread -213305584 is running in processor 6thread -213305584 is running in processor 7thread -230090992 is running in processor 0thread -230090992 is running in processor 1thread -230090992 is running in processor 2thread -204912880 is running in processor 0thread -204912880 is running in processor 1thread -204912880 is running in processor 2thread -238483696 is running in processor 0thread -230090992 is running in processor 3由以上结果可以看出linux是不会默认对线程进行和CPU进行绑定的如果有需要必须自己显式的调用函数绑定。3. 结论线程与CPU进行绑定可以减少线程在不同核之间切换的开销但是要遵循一定的规则并不是每个线程都与特定CPU绑定效率高。一般来说计算密集型的程序与CPU绑定与不绑定相比效果要好得多但对于IO密集型的程序来说影响不是太大。
http://www.yutouwan.com/news/37247/

相关文章:

  • 网站分析论文建站程序
  • 网站打开403中国世界排名前100的大学
  • ftp上传网站 需要什么文件网页前端模板网站
  • 怎么建设游网站主页咸宁市做网站
  • 做电子商务网站需要什么手续科技设计公司网站模板
  • 如何做网站定位广州网站开发 找亦客公司优质
  • 怎么建设国际网站网站全站搜索代码
  • 白酒网站源码网站开发实训报告总结2021
  • 免费建立企业网站网站绑定微信公众号
  • 汉口网站建设制作网站设计工
  • 企业网站后台管理软件网站建设提案怎么写
  • 临沂市建设工程多图联审系统 网站怎么用ps做网站超链接
  • 网站开发研究背景网页设计作业文件
  • 网站建设完成确认书展会搭建设计案例网站
  • 网站建设知识论文代理游戏网站
  • 网站搭建网平面设计学徒工资一般多少
  • 古腾堡布局的网站相关网站怎么做
  • 工会 网站 建设合肥做推拉棚网站推广
  • 域名出售网站阿里云域名注册流程
  • 昌邑网站建设seo自学网视频教程
  • 创建网站开发公司服务器做网站数据库
  • 网站建设与管理ppt模板下载wordpress免费建站
  • 合肥科技职业学院网站建设与管理做app模板网站有哪些内容
  • seo查询是什么商城网站不易优化
  • 网站开发的背景知识与相关技术做p2p投资理财的网站
  • 网站的锚点链接怎么做代运营公司
  • wap网站如何建设网站建设的核心是什么
  • 长春住房和城乡建设部官方网站关于动漫的网站建设
  • 无锡时光科技网站建设公司怎么样江苏林润建设工程有限公司网站
  • 一站式网页设计服务平台网页设计公司的目标客户有哪些