Message-Id: <200310310514.h9V5ESqI028308@delorie.com> Mailing-List: contact cygwin-help AT cygwin DOT com; run by ezmlm List-Subscribe: List-Archive: List-Post: List-Help: , Sender: cygwin-owner AT cygwin DOT com Mail-Followup-To: cygwin AT cygwin DOT com Delivered-To: mailing list cygwin AT cygwin DOT com Date: Fri, 31 Oct 2003 13:14:17 +0800 From: "zhouxin" To: "cygwin AT cygwin DOT com" Subject: select() take 100% CPU with cygwin1.5.5-1 in WinXP/Win2000 Mime-Version: 1.0 Content-Type: text/plain; charset="GB2312" Content-Transfer-Encoding: 7bit Cygwin implementation of select() take 100% CPU under multi-thread environment sometimes. I have wrote a short test program(see below test_select.c) that reproduces the bug: #uname -a CYGWIN_NT-5.1 zipxing 1.5.5(0.94/3/2) 2003-09-20 16:31 i686 unknown #gcc -o tsel test_select.c #./tsel 5 (5 threads, no problem) ^C #./tsel 17(17 threads, no problem) ^C #./tsel 18(18 threads, tsel take 100% cpu!!! It seems that 18 is a critical value.) and I compile and execute test_select.c in solaris9,all ok... Is this a bug of Cygwin implementation of select()? help,thanks! test_select.c ___________________________________________________________________ #include #include #include #include #include #include #include //Select timeout... int timeout = 30; //Thread count... int tcount = 20; //Thread function... void * tp(void *ptr) { int sockfd = 0; int tid; tid = (int)ptr; if((sockfd = socket(AF_INET, SOCK_DGRAM, 0)) < 0){ fprintf(stderr, "cannot open socket for udp packet!\n"); exit(1); } while(1){ struct timeval tv; fd_set fds; FD_ZERO(&fds); FD_SET(sockfd, &fds); tv.tv_sec = timeout; tv.tv_usec = 0; printf("select the socket_fd : %d, thread_id is : %d\n", sockfd, tid); select(sockfd + 1, &fds, NULL, NULL, &tv); } } //Initial thread pool... void thread_pool_init() { int i; pthread_t thrid; for(i=0; i1) tcount = atoi(argv[1]); thread_pool_init(); while(1){ sleep(10000); } } _____________________________________________________________________________________ -- Unsubscribe info: http://cygwin.com/ml/#unsubscribe-simple Problem reports: http://cygwin.com/problems.html Documentation: http://cygwin.com/docs.html FAQ: http://cygwin.com/faq/