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

flask做的网站项目在百度做推广需要网站

flask做的网站项目,在百度做推广需要网站,百度热词搜索指数,网站开发 家具销售 文献这个例程为使用多线程配合互斥量进行点乘计算#xff0c;相关的数据通过全局变量的形式存在#xff0c;因此可以被各个线程访问#xff1b;每个线程会在相关数据的不同区域上进行处理#xff0c;主线程等待子线程完成操作后#xff0c;将最后的结果打印出来。 代码如下 #…        这个例程为使用多线程配合互斥量进行点乘计算相关的数据通过全局变量的形式存在因此可以被各个线程访问每个线程会在相关数据的不同区域上进行处理主线程等待子线程完成操作后将最后的结果打印出来。 代码如下 #include pthread.h #include stdio.h #include stdlib.h/* The following structure contains the necessary information* to allow the function dotprod to access its input data and* place its output into the structure.*/typedef struct {double *a;double *b;double sum;int veclen; } DOTDATA;/* Define globally accessible variables and a mutex */#define NUMTHRDS 4 #define VECLEN 100DOTDATA dotstr; pthread_t callThd[NUMTHRDS]; pthread_mutex_t mutexsum;/* The function dotprod is activated when the thread is created.* All input to this routine is obtained from a structure* of type DOTDATA and all output from this function is written into* this structure. The benefit of this approach is apparent for the* multi-threaded program: when a thread is created we pass a single* argument to the activated function - typically this argument* is a thread number. All the other information required by the* function is accessed from the globally accessible structure.*/void *dotprod(void *arg) {/* Define and use local variables for convenience */int i, start, end, len;long offset;double mysum, *x, *y;offset (long)arg;len dotstr.veclen;start offset * len;end start len;x dotstr.a;y dotstr.b;/*Perform the dot product and assign resultto the appropriate variable in the structure.*/mysum 0;for (i start; i end ; i) {mysum (x[i] * y[i]);}/*Lock a mutex prior to updating the value in the sharedstructure, and unlock it upon updating.*/pthread_mutex_lock(mutexsum);dotstr.sum mysum;pthread_mutex_unlock(mutexsum);pthread_exit((void*) 0); }/* The main program creates threads which do all the work and then* print out result upon completion. Before creating the threads,* the input data is created. Since all threads update a shared structure,* we need a mutex for mutual exclusion. The main thread needs to wait for* all threads to complete, it waits for each one of the threads. We specify* a thread attribute value that allow the main thread to join with the* threads it creates. Note also that we free up handles when they are* no longer needed.*/int main (int argc, char *argv[]) {long i;double *a, *b;void *status;pthread_attr_t attr;/* Assign storage and initialize values */a (double*) malloc (NUMTHRDS * VECLEN * sizeof(double));b (double*) malloc (NUMTHRDS * VECLEN * sizeof(double));for (i 0; i VECLEN * NUMTHRDS; i) {a[i] 1.0;b[i] a[i];}dotstr.veclen VECLEN;dotstr.a a;dotstr.b b;dotstr.sum 0;pthread_mutex_init(mutexsum, NULL);/* Create threads to perform the dot product */pthread_attr_init(attr);pthread_attr_setdetachstate(attr, PTHREAD_CREATE_JOINABLE);for(i 0; i NUMTHRDS; i) {/* Each thread works on a different set of data. The offset is specified* by i. The size of the data for each thread is indicated by VECLEN.*/pthread_create(callThd[i], attr, dotprod, (void *)i);}pthread_attr_destroy(attr);/* Wait on the other threads */for(i 0; i NUMTHRDS; i) {pthread_join(callThd[i], status);}/* After joining, print out the results and cleanup */printf(Sum %f\n, dotstr.sum);free(a);free(b);pthread_mutex_destroy(mutexsum);pthread_exit(NULL); }
http://www.eeditor.cn/news/124817/

相关文章:

  • 廉江手机网站建设天津猎头公司
  • 怎么做自己的品牌网站访问一个网站的过程
  • 网站建设wuliankj微信官方公众号
  • 小说类型网站怎么做旅游网站开发意义
  • 泉州专业网站建设哪家好南阳专业做网站公司哪家好
  • 网站分析实例网站后台 教程
  • 广州网页设计网站apache 配置网站
  • 杭州电商网站开发聚财洋气三个字公司名字
  • wordpress多站点免费网站模板psd
  • 宁波建设安全协会网站做网站是什么公司
  • 十大必做调查网站千锋教育地址
  • 亿度网络 网站建设蛇口网站建设
  • 公司网站建设服务费计入什么科目php网站开发课程
  • 张家界建设企业网站名词解释 网站规划
  • 想建设一个网站wordpress 禁用 提示
  • 南京外贸网站建设哪家好博客网站怎么做cpa
  • wordpress 企业站主题新手学做网站下载
  • flashfxp上传网站公司简介英语作文
  • 济南手机网站建设公司报价深圳建设工程交易中心主页
  • 企业的网站建设文章小程序后端怎么开发
  • 建网站的要求青岛免费网站建设
  • 烟台牟平住房建设局网站网站制作答辩ppt怎么做
  • 国外优秀网站案例wordpress 字符转义
  • 响应式网站建设模板下载化妆品网站开发步骤
  • 永兴网站制作如何防止网站被注册
  • 做足球经理头像的网站如何注册公司名称
  • 做家教什么网站高端 网站开发
  • 潍坊网站优化培训石家庄网络平台推广
  • 如何给自己的公司做网站app定制软件开发
  • 苏州网站建设提供商网站开发公司需要哪些部门