From owner-freebsd-threads@FreeBSD.ORG Sun Nov 16 19:20:02 2008 Return-Path: Delivered-To: freebsd-threads@hub.freebsd.org Received: from mx1.freebsd.org (mx1.freebsd.org [IPv6:2001:4f8:fff6::34]) by hub.freebsd.org (Postfix) with ESMTP id 24D361065686 for ; Sun, 16 Nov 2008 19:20:02 +0000 (UTC) (envelope-from gnats@FreeBSD.org) Received: from freefall.freebsd.org (freefall.freebsd.org [IPv6:2001:4f8:fff6::28]) by mx1.freebsd.org (Postfix) with ESMTP id 06E558FC1A for ; Sun, 16 Nov 2008 19:20:02 +0000 (UTC) (envelope-from gnats@FreeBSD.org) Received: from freefall.freebsd.org (gnats@localhost [127.0.0.1]) by freefall.freebsd.org (8.14.3/8.14.3) with ESMTP id mAGJK1J6032831 for ; Sun, 16 Nov 2008 19:20:01 GMT (envelope-from gnats@freefall.freebsd.org) Received: (from gnats@localhost) by freefall.freebsd.org (8.14.3/8.14.3/Submit) id mAGJK151032830; Sun, 16 Nov 2008 19:20:01 GMT (envelope-from gnats) Resent-Date: Sun, 16 Nov 2008 19:20:01 GMT Resent-Message-Id: <200811161920.mAGJK151032830@freefall.freebsd.org> Resent-From: FreeBSD-gnats-submit@FreeBSD.org (GNATS Filer) Resent-To: freebsd-threads@FreeBSD.org Resent-Reply-To: FreeBSD-gnats-submit@FreeBSD.org, Peter Received: from mx1.freebsd.org (mx1.freebsd.org [IPv6:2001:4f8:fff6::34]) by hub.freebsd.org (Postfix) with ESMTP id 510451065678 for ; Sun, 16 Nov 2008 19:18:04 +0000 (UTC) (envelope-from nobody@FreeBSD.org) Received: from www.freebsd.org (www.freebsd.org [IPv6:2001:4f8:fff6::21]) by mx1.freebsd.org (Postfix) with ESMTP id 452488FC19 for ; Sun, 16 Nov 2008 19:18:04 +0000 (UTC) (envelope-from nobody@FreeBSD.org) Received: from www.freebsd.org (localhost [127.0.0.1]) by www.freebsd.org (8.14.3/8.14.3) with ESMTP id mAGJI4fX086650 for ; Sun, 16 Nov 2008 19:18:04 GMT (envelope-from nobody@www.freebsd.org) Received: (from nobody@localhost) by www.freebsd.org (8.14.3/8.14.3/Submit) id mAGJI4TI086649; Sun, 16 Nov 2008 19:18:04 GMT (envelope-from nobody) Message-Id: <200811161918.mAGJI4TI086649@www.freebsd.org> Date: Sun, 16 Nov 2008 19:18:04 GMT From: Peter To: freebsd-gnats-submit@FreeBSD.org X-Send-Pr-Version: www-3.1 Cc: Subject: threads/128922: threads hang with xorg running X-BeenThere: freebsd-threads@freebsd.org X-Mailman-Version: 2.1.5 Precedence: list List-Id: Threading on FreeBSD List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Sun, 16 Nov 2008 19:20:02 -0000 >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 #include #include #include 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 #include #include #include 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: