Skip site navigation (1)Skip section navigation (2)
Date:      Wed, 25 Jul 2001 14:12:06 +0300
From:      Maxim Sobolev <sobomax@FreeBSD.org>
To:        current@FreeBSD.org
Cc:        Julian Elischer <julian@elischer.org>, stable@FreeBSD.org
Subject:   Strange select(2) misbehaviour when linked with -pthread
Message-ID:  <3B5EA985.458B39B7@FreeBSD.org>

next in thread | raw e-mail | index | archive | help
This is a multi-part message in MIME format.
--------------45E7A6BD8D2F3ADC6B9063B1
Content-Type: text/plain; charset=koi8-r
Content-Transfer-Encoding: 7bit

Hi,

I found that the attached small program behaves very strangely when
linked with -pthread - it chews 100% CPU cycles while waiting in
select(2). This misbehaviour observed both on 5-CURRENT and 4-STABLE
systems. *weird*

-Maxim
P.S. And yes, I know that I ought to use NULL instead of &tv when I
want to wait indefinitely in select(2), but it is how some programs
work.

--------------45E7A6BD8D2F3ADC6B9063B1
Content-Type: text/plain; charset=koi8-r;
 name="selectbug.c"
Content-Transfer-Encoding: 7bit
Content-Disposition: inline;
 filename="selectbug.c"

#include <stdio.h>
#include <string.h>
#include <sys/types.h>
#include <sys/time.h>
#include <unistd.h>

int main()
{
	int retval, fd;
	u_int32_t timeout;
	struct timeval tv;
	fd_set mask;

	fd = 0;
	timeout = ~0;
	tv.tv_sec = timeout/1000;
	tv.tv_usec = (timeout%1000)*1000;
	FD_ZERO(&mask);
	FD_SET(fd, &mask);

	retval = select(1, &mask, NULL, NULL, &tv);
	exit(0);
}

--------------45E7A6BD8D2F3ADC6B9063B1--


To Unsubscribe: send mail to majordomo@FreeBSD.org
with "unsubscribe freebsd-current" in the body of the message




Want to link to this message? Use this URL: <https://mail-archive.FreeBSD.org/cgi/mid.cgi?3B5EA985.458B39B7>