threads/128922: threads hang with xorg running

Peter dreigcht at gmail.com
Sun Nov 16 11:20:02 PST 2008


>Number:         128922
>Category:       threads
>Synopsis:       threads hang with xorg running
>Confidential:   no
>Severity:       serious
>Priority:       medium
>Responsible:    freebsd-threads
>State:          open
>Quarter:        
>Keywords:       
>Date-Required:
>Class:          sw-bug
>Submitter-Id:   current-users
>Arrival-Date:   Sun Nov 16 19:20:01 UTC 2008
>Closed-Date:
>Last-Modified:
>Originator:     Peter
>Release:        7.0
>Organization:
Private
>Environment:
FreeBSD  7.0-RELEASE-p5 amd64
>Description:
 The following program runs perfectly on FreeBSD 6.3 amd64 (with xorg running
and without xorg running).

 But on FreeBSD 7.0 amd64 and 7.1 beta amd64 (only with xorg running) 
after a few seconds of working the thread "period_thread" hangs printing 
only one time a second and even less. Moreover, the whole system becomes slow 
though "top" does not show a heavy load.
 Tried on Intel E6600 and on Intel E1200 with the same result.
 Tried with GENERIC kernel "out of the box" and with my kernel configurations with the same result.
 Tried with 4BSD and ULE schedulers with the same result.


#include <stdlib.h>
#include <stdio.h>

#include <pthread.h>
#include <unistd.h>


void* thread(void* q)
{
	const size_t SIZE = 500;
	volatile double vec[SIZE];
	
	size_t cnt;
	for(cnt = 0; cnt < 1000000; ++cnt)
	{
		size_t i;
		for(i = 0; i < SIZE; ++i)
		{
			vec[i] = 0;
		}
		for(i = 0; i < SIZE; ++i)
		{
			vec[i] += i;
			vec[i] -= i;
		}
	}

}

void* period_thread(void* q)
{
	int i;
	for(i = 0;;++i)
	{
		printf("period thread %i\n", i);
		usleep( 50 * 1000 );
	}
}

int main( int argc, char** argv )
{

	pthread_t hs;
	pthread_create(&hs, NULL, period_thread, NULL);

	for(;;)
	{
		const size_t SIZE = 5;
		pthread_t h[SIZE];
	
		size_t i;
		for(i = 0; i < SIZE; ++i)
		{
			pthread_create( &h[i], NULL, thread, NULL);
		}

		for(i = 0; i < SIZE; ++i)
		{
			pthread_join(h[i], NULL);
		}
	}
} 















>How-To-Repeat:
Run the program on FreeBSD 7.0 amd64 or 7.1 beta amd64 in xterm, konsole, etc 
(xorg running).
>Fix:


Patch attached with submission follows:

#include <stdlib.h>
#include <stdio.h>

#include <pthread.h>
#include <unistd.h>


void* thread(void* q)
{
	const size_t SIZE = 500;
	volatile double vec[SIZE];
	
	size_t cnt;
	for(cnt = 0; cnt < 1000000; ++cnt)
	{
		size_t i;
		for(i = 0; i < SIZE; ++i)
		{
			vec[i] = 0;
		}
		for(i = 0; i < SIZE; ++i)
		{
			vec[i] += i;
			vec[i] -= i;
		}
	}

}

void* period_thread(void* q)
{
	int i;
	for(i = 0;;++i)
	{
		printf("period thread %i\n", i);
		usleep( 50 * 1000 );
	}
}

int main( int argc, char** argv )
{

	pthread_t hs;
	pthread_create(&hs, NULL, period_thread, NULL);

	for(;;)
	{
		const size_t SIZE = 5;
		pthread_t h[SIZE];
	
		size_t i;
		for(i = 0; i < SIZE; ++i)
		{
			pthread_create( &h[i], NULL, thread, NULL);
		}

		for(i = 0; i < SIZE; ++i)
		{
			pthread_join(h[i], NULL);
		}
	}
} 


>Release-Note:
>Audit-Trail:
>Unformatted:


More information about the freebsd-threads mailing list