亚洲欧美第一页_禁久久精品乱码_粉嫩av一区二区三区免费野_久草精品视频

? 歡迎來到蟲蟲下載站! | ?? 資源下載 ?? 資源專輯 ?? 關于我們
? 蟲蟲下載站

?? eyal1.c

?? pthread source code,you can compile directly
?? C
字號:
/* Simple POSIX threads program. * * * -------------------------------------------------------------------------- * *      Pthreads-win32 - POSIX Threads Library for Win32 *      Copyright(C) 1998 John E. Bossom *      Copyright(C) 1999,2005 Pthreads-win32 contributors *  *      Contact Email: rpj@callisto.canberra.edu.au *  *      The current list of contributors is contained *      in the file CONTRIBUTORS included with the source *      code distribution. The list can also be seen at the *      following World Wide Web location: *      http://sources.redhat.com/pthreads-win32/contributors.html *  *      This library is free software; you can redistribute it and/or *      modify it under the terms of the GNU Lesser General Public *      License as published by the Free Software Foundation; either *      version 2 of the License, or (at your option) any later version. *  *      This library is distributed in the hope that it will be useful, *      but WITHOUT ANY WARRANTY; without even the implied warranty of *      MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU *      Lesser General Public License for more details. *  *      You should have received a copy of the GNU Lesser General Public *      License along with this library in the file COPYING.LIB; *      if not, write to the Free Software Foundation, Inc., *      59 Temple Place - Suite 330, Boston, MA 02111-1307, USA * * -------------------------------------------------------------------------- * * Author: Eyal Lebedinsky eyal@eyal.emu.id.au * Written: Sep 1998. * Version Date: 12 Sep 1998 * * Do we need to lock stdout or is it thread safe? * * Used: *	pthread_t *	pthread_attr_t *	pthread_create() *	pthread_join() *	pthread_mutex_t *	PTHREAD_MUTEX_INITIALIZER *	pthread_mutex_init() [not used now] *	pthread_mutex_destroy() *	pthread_mutex_lock() *	pthread_mutex_trylock() *	pthread_mutex_unlock() * * What this program does is establish a work queue (implemented using * four mutexes for each thread). It then schedules work (by storing * a number in 'todo') and releases the threads. When the work is done * the threads will block. The program then repeats the same thing once * more (just to test the logic) and when the work is done it destroyes * the threads. * * The 'work' we do is simply burning CPU cycles in a loop. * The 'todo' work queue is trivial - each threads pops one element * off it by incrementing it, the poped number is the 'work' to do. * When 'todo' reaches the limit (nwork) the queue is considered * empty. * * The number displayed at the end is the amount of work each thread * did, so we can see if the load was properly distributed. * * The program was written to test a threading setup (not seen here) * rather than to demonstrate correct usage of the pthread facilities. * * Note how each thread is given access to a thread control structure * (TC) which is used for communicating to/from the main program (e.g. * the threads knows its 'id' and also filles in the 'work' done).*/#include "test.h"#include <stdlib.h>#include <math.h>struct thread_control {  int		id;  pthread_t	thread;		/* thread id */  pthread_mutex_t	mutex_start;  pthread_mutex_t	mutex_started;  pthread_mutex_t	mutex_end;  pthread_mutex_t	mutex_ended;  long		work;		/* work done */  int		stat;		/* pthread_init status */};typedef struct thread_control	TC;static TC		*tcs = NULL;static int		nthreads = 10;static int		nwork = 100;static int		quiet = 0;static int		todo = -1;static pthread_mutex_t	mutex_todo = PTHREAD_MUTEX_INITIALIZER;static pthread_mutex_t	mutex_stdout = PTHREAD_MUTEX_INITIALIZER;static voiddie (int ret){  if (NULL != tcs)    {      free (tcs);      tcs = NULL;    }  if (ret)    exit (ret);}static doublewaste_time (int n){  int		i;  double	f, g, h, s;  s = 0.0;  /*   * Useless work.   */  for (i = n*100; i > 0; --i)    {      f = rand ();      g = rand ();      h = rand ();      s += 2.0 * f * g / (h != 0.0 ? (h * h) : 1.0);    }  return s;}static intdo_work_unit (int who, int n){  int		i;  static int	nchars = 0;  double	f = 0.0;  if (quiet)    i = 0;  else {    /*     * get lock on stdout     */    assert(pthread_mutex_lock (&mutex_stdout) == 0);    /*     * do our job     */    i = printf ("%c", "0123456789abcdefghijklmnopqrstuvwxyz"[who]);    if (!(++nchars % 50))      printf ("\n");    fflush (stdout);    /*     * release lock on stdout     */    assert(pthread_mutex_unlock (&mutex_stdout) == 0);  }  n = rand () % 10000;	/* ignore incoming 'n' */  f = waste_time (n);  /* This prevents the statement above from being optimised out */  if (f > 0.0)    return(n);  return (n);}static intprint_server (void *ptr){  int		mywork;  int		n;  TC		*tc = (TC *)ptr;  assert(pthread_mutex_lock (&tc->mutex_started) == 0);  for (;;)    {      assert(pthread_mutex_lock (&tc->mutex_start) == 0);      assert(pthread_mutex_unlock (&tc->mutex_start) == 0);      assert(pthread_mutex_lock (&tc->mutex_ended) == 0);      assert(pthread_mutex_unlock (&tc->mutex_started) == 0);      for (;;)	{	  /*	   * get lock on todo list	   */	  assert(pthread_mutex_lock (&mutex_todo) == 0);	  mywork = todo;	  if (todo >= 0)	    {	      ++todo;	      if (todo >= nwork)		todo = -1;	    }	  assert(pthread_mutex_unlock (&mutex_todo) == 0);	  if (mywork < 0)	    break;	  assert((n = do_work_unit (tc->id, mywork)) >= 0);	  tc->work += n;	}      assert(pthread_mutex_lock (&tc->mutex_end) == 0);      assert(pthread_mutex_unlock (&tc->mutex_end) == 0);      assert(pthread_mutex_lock (&tc->mutex_started) == 0);      assert(pthread_mutex_unlock (&tc->mutex_ended) == 0);      if (-2 == mywork)	break;    }  assert(pthread_mutex_unlock (&tc->mutex_started) == 0);  return (0);}static voiddosync (void){  int		i;  for (i = 0; i < nthreads; ++i)    {      assert(pthread_mutex_lock (&tcs[i].mutex_end) == 0);      assert(pthread_mutex_unlock (&tcs[i].mutex_start) == 0);      assert(pthread_mutex_lock (&tcs[i].mutex_started) == 0);      assert(pthread_mutex_unlock (&tcs[i].mutex_started) == 0);    }  /*   * Now threads do their work   */  for (i = 0; i < nthreads; ++i)    {      assert(pthread_mutex_lock (&tcs[i].mutex_start) == 0);      assert(pthread_mutex_unlock (&tcs[i].mutex_end) == 0);      assert(pthread_mutex_lock (&tcs[i].mutex_ended) == 0);      assert(pthread_mutex_unlock (&tcs[i].mutex_ended) == 0);    }}static voiddowork (void){  todo = 0;  dosync();  todo = 0;  dosync();}intmain (int argc, char *argv[]){  int		i;  assert(NULL != (tcs = (TC *) calloc (nthreads, sizeof (*tcs))));  /*    * Launch threads   */  for (i = 0; i < nthreads; ++i)    {      tcs[i].id = i;      assert(pthread_mutex_init (&tcs[i].mutex_start, NULL) == 0);      assert(pthread_mutex_init (&tcs[i].mutex_started, NULL) == 0);      assert(pthread_mutex_init (&tcs[i].mutex_end, NULL) == 0);      assert(pthread_mutex_init (&tcs[i].mutex_ended, NULL) == 0);      tcs[i].work = 0;        assert(pthread_mutex_lock (&tcs[i].mutex_start) == 0);      assert((tcs[i].stat = 	      pthread_create (&tcs[i].thread,			      NULL,                  (void *(*)(void *))print_server,                (void *) &tcs[i])	      ) == 0);      /*        * Wait for thread initialisation       */      {	int trylock = 0;	while (trylock == 0)	  {	    trylock = pthread_mutex_trylock(&tcs[i].mutex_started);	    assert(trylock == 0 || trylock == EBUSY);	    if (trylock == 0)	      {		assert(pthread_mutex_unlock (&tcs[i].mutex_started) == 0);	      }	  }      }    }  dowork ();  /*   * Terminate threads   */  todo = -2;	/* please terminate */  dosync();  for (i = 0; i < nthreads; ++i)    {      if (0 == tcs[i].stat)	assert(pthread_join (tcs[i].thread, NULL) == 0);    }  /*    * destroy locks   */  assert(pthread_mutex_destroy (&mutex_stdout) == 0);  assert(pthread_mutex_destroy (&mutex_todo) == 0);  /*   * Cleanup   */  printf ("\n");  /*   * Show results   */  for (i = 0; i < nthreads; ++i)    {      printf ("%2d ", i);      if (0 == tcs[i].stat)	printf ("%10ld\n", tcs[i].work);      else	printf ("failed %d\n", tcs[i].stat);      assert(pthread_mutex_unlock(&tcs[i].mutex_start) == 0);      assert(pthread_mutex_destroy (&tcs[i].mutex_start) == 0);      assert(pthread_mutex_destroy (&tcs[i].mutex_started) == 0);      assert(pthread_mutex_destroy (&tcs[i].mutex_end) == 0);      assert(pthread_mutex_destroy (&tcs[i].mutex_ended) == 0);    }  die (0);  return (0);}

?? 快捷鍵說明

復制代碼 Ctrl + C
搜索代碼 Ctrl + F
全屏模式 F11
切換主題 Ctrl + Shift + D
顯示快捷鍵 ?
增大字號 Ctrl + =
減小字號 Ctrl + -
亚洲欧美第一页_禁久久精品乱码_粉嫩av一区二区三区免费野_久草精品视频
精品在线免费观看| 欧美日韩黄色影视| 国产一区二区0| 卡一卡二国产精品 | 一区二区三区日韩在线观看| 国产欧美一区二区三区在线老狼| 欧美不卡一二三| 精品久久久久久久久久久久久久久久久| 欧美天堂亚洲电影院在线播放| 一本色道久久加勒比精品| 色婷婷久久久久swag精品| 色综合天天综合在线视频| 色哟哟国产精品| 欧美视频日韩视频在线观看| 欧美日韩精品久久久| 欧美揉bbbbb揉bbbbb| 欧美三级日韩三级国产三级| 欧美日韩美女一区二区| 在线成人av影院| 在线成人av网站| 欧美videofree性高清杂交| 久久亚洲精精品中文字幕早川悠里| 欧美精品一区二区三区高清aⅴ| 久久久综合网站| 国产欧美日韩精品一区| 中文字幕综合网| 一区二区三区精品在线观看| 午夜私人影院久久久久| 美女任你摸久久| 国产xxx精品视频大全| aaa欧美色吧激情视频| 欧洲一区二区三区在线| 日韩一级完整毛片| 中文字幕精品一区| 夜夜揉揉日日人人青青一国产精品| 午夜激情综合网| 国内精品国产成人| 成人av网站免费| 欧美日韩电影一区| 欧美精品一区二区三区一线天视频 | 在线观看欧美黄色| 欧美一区二区三区四区视频| 国产亚洲精品免费| 亚洲色图在线看| 青草av.久久免费一区| 国产精品一区二区男女羞羞无遮挡| 成人av电影观看| 7777精品伊人久久久大香线蕉完整版 | 国产成人精品www牛牛影视| 日本精品视频一区二区三区| 91精品国产色综合久久| 国产亚洲精品aa午夜观看| 一区二区三区高清在线| 免费不卡在线观看| 99re成人在线| 欧美大片拔萝卜| 亚洲天堂免费在线观看视频| 五月天欧美精品| av在线综合网| 日韩欧美三级在线| 亚洲欧美偷拍三级| 另类小说综合欧美亚洲| 91天堂素人约啪| 欧美电影免费观看高清完整版在| 亚洲精品欧美在线| 国产成人精品影视| 日韩免费成人网| 亚洲一区二区在线视频| 国产成人精品影院| 精品1区2区在线观看| 亚洲成人激情社区| 暴力调教一区二区三区| 久久综合九色欧美综合狠狠| 亚洲高清在线视频| 91免费观看视频| 国产亚洲综合av| 激情综合亚洲精品| 欧美精品国产精品| 一区二区三区成人| 91在线视频在线| 国产日韩欧美一区二区三区综合| 天堂蜜桃91精品| 91免费视频网址| 日韩欧美专区在线| 免费精品视频最新在线| 91啪在线观看| 久久中文娱乐网| 亚洲一区二区高清| 成人激情黄色小说| 欧美成人国产一区二区| 亚洲日穴在线视频| 国产精品主播直播| 91超碰这里只有精品国产| 中文字幕在线观看不卡视频| 青青草一区二区三区| 欧美亚洲自拍偷拍| 亚洲视频免费观看| 波多野结衣在线aⅴ中文字幕不卡 波多野结衣在线一区 | 麻豆国产精品一区二区三区| 国产91丝袜在线观看| 久久午夜羞羞影院免费观看| 亚洲bt欧美bt精品| 91美女在线观看| 国产欧美精品区一区二区三区 | 国产sm精品调教视频网站| 欧美日韩免费不卡视频一区二区三区| 欧美激情资源网| 精品一区二区三区在线视频| 欧美男人的天堂一二区| 国产亚洲1区2区3区| 国产高清无密码一区二区三区| 91精品国产综合久久精品性色 | 亚洲综合色区另类av| 色吊一区二区三区| 日韩一区欧美小说| 床上的激情91.| 国产日本欧美一区二区| 国产一区二区三区精品欧美日韩一区二区三区 | 欧美一级电影网站| 丝袜诱惑亚洲看片| 成人午夜电影网站| 日韩欧美国产不卡| 日本强好片久久久久久aaa| 欧美日韩成人综合| 午夜伊人狠狠久久| 欧美剧情电影在线观看完整版免费励志电影 | 日韩精品电影在线| 欧美日韩视频专区在线播放| 亚洲成在人线免费| 欧美日韩dvd在线观看| 亚洲va欧美va国产va天堂影院| 欧美伊人久久久久久午夜久久久久| 成人免费一区二区三区视频| 91天堂素人约啪| 国产欧美日韩视频在线观看| 99久久777色| 亚洲小说春色综合另类电影| 欧美午夜在线观看| 奇米影视一区二区三区小说| 日韩欧美国产高清| 国产精品一区二区你懂的| 亚洲精选视频在线| 欧美日韩国产不卡| 免费的成人av| 国产亚洲精品超碰| 色天使色偷偷av一区二区| 亚洲曰韩产成在线| 精品国产欧美一区二区| 国产一区二区福利视频| 国产精品久久久久久久第一福利| 91网站最新地址| 亚洲成av人片在线| 欧美成人欧美edvon| 激情图片小说一区| 有码一区二区三区| 欧美一区二区三区日韩视频| 国产一区二区三区四区五区入口 | 久久精品免费看| 日本不卡免费在线视频| 极品少妇xxxx精品少妇偷拍| 看电影不卡的网站| 99久久精品情趣| 91久久精品一区二区二区| 成人午夜碰碰视频| 欧美一区欧美二区| 日韩欧美中文字幕精品| 精品少妇一区二区三区视频免付费| 欧美va亚洲va香蕉在线| 亚洲欧美国产毛片在线| 亚洲同性同志一二三专区| 蜜桃精品视频在线观看| av激情综合网| 4438x亚洲最大成人网| 亚洲欧洲精品一区二区三区不卡| 九九精品视频在线看| 国产精品影视在线观看| 欧美一区日本一区韩国一区| 国产亚洲欧美日韩日本| 亚洲欧美在线视频| 亚洲一二三四久久| 国产精品一区二区在线观看网站| 国产999精品久久久久久| 色综合久久88色综合天天| 精品久久久久一区二区国产| 欧美白人最猛性xxxxx69交| 中文字幕第一区| 丝袜脚交一区二区| 97精品国产露脸对白| 欧美人xxxx| ●精品国产综合乱码久久久久| 久久久电影一区二区三区| 亚洲在线观看免费| 成人午夜视频福利| 2021久久国产精品不只是精品| 成人欧美一区二区三区| 国内一区二区视频| 欧美老年两性高潮| 一区二区三区在线视频播放 | 亚洲电影在线播放| 日本强好片久久久久久aaa|