From owner-freebsd-hackers@FreeBSD.ORG Tue Jan 25 16:34:06 2005 Return-Path: Delivered-To: freebsd-hackers@freebsd.org Received: from mx1.FreeBSD.org (mx1.freebsd.org [216.136.204.125]) by hub.freebsd.org (Postfix) with ESMTP id CBF4D16A4CE for ; Tue, 25 Jan 2005 16:34:06 +0000 (GMT) Received: from mx.hostarica.com (mx.hostarica.com [196.40.45.74]) by mx1.FreeBSD.org (Postfix) with ESMTP id 41FDD43D41 for ; Tue, 25 Jan 2005 16:34:06 +0000 (GMT) (envelope-from jose@hostarica.com) Received: from localhost (localhost.hostarica.com [127.0.0.1]) by mx.hostarica.com (Postfix) with ESMTP id B5537F6A6; Tue, 25 Jan 2005 10:24:25 -0600 (CST) Received: from localhost.localdomain (jose.hostarica.net [192.168.0.69]) (using TLSv1 with cipher RC4-MD5 (128/128 bits)) (No client certificate requested) by mx.hostarica.com (Postfix) with ESMTP id 7E1C5F6A1; Tue, 25 Jan 2005 10:24:24 -0600 (CST) From: Jose Hidalgo Herrera To: Yan Yu In-Reply-To: References: Content-Type: text/plain Organization: Corp. Hostarica Date: Tue, 25 Jan 2005 10:14:21 -0600 Message-Id: <1106669661.9523.7.camel@jose.hostarica.net> Mime-Version: 1.0 X-Mailer: Evolution 2.0.2 FreeBSD GNOME Team Port Content-Transfer-Encoding: 7bit X-Virus-Scanned: by amavisd 0.1 cc: freebsd-hackers@freebsd.org cc: jose@hostarica.com Subject: Re: seg fault on kse_release () (fwd) X-BeenThere: freebsd-hackers@freebsd.org X-Mailman-Version: 2.1.1 Precedence: list Reply-To: jose@hostarica.com List-Id: Technical Discussions relating to FreeBSD List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Tue, 25 Jan 2005 16:34:06 -0000 I ran it into: 4.11-STABLE FreeBSD Wed Jan 19 15:23:33 CST 2005 What you find in http://www1.cr.freebsd.org/~jose/stress.tgz is the output of: ktrace ./a.out > stress.txt On Mon, 2005-01-24 at 14:27 -0800, Yan Yu wrote: > Hi, all, I have a newbie Q: > I am trying to use creating large number of threads and allocting > memory to stress the system. > My user program causes SEG fault in the kernel code, kse_release () in > kern_kse.c. > (it SEG fault before the system can be stressed;( > > the stack when the SEG fault happens are: > #0 0x08064e54 in kse_release () > #1 0x080531c4 in kse_sched_single () > #2 0x00000000 in ?? () > > My simple program is: > I have a simple function to create threads: > > #define NUM_THREADS 5000 > #define THREADS_IN_ONE_PROCESS 5 > #define BSIZE 500000 > static int cc; > > void CreateThread(int n) > { > assert( n <= NUM_THREADS ); > pthread_t threads[NUM_THREADS]; > int rc, t; > for(t=0;t < n;t++){ > printf("#%d: Creating thread %d\n", cc, t); > cc++; > rc = pthread_create(&threads[t], NULL, PrintHello, (void *)t); > if (rc){ > printf("ERROR; return code from pthread_create() is %d\n", rc); > } > } > > unsigned long id; > char * p = (char *) calloc(BSIZE, sizeof(char) ); > if ( p == NULL ) > { > fprintf(stderr, "calloc error\n"); > } > while (1) > { > while (BSIZE <= (id = rand() / (RAND_MAX/BSIZE))); > p[id] ++; > } > } > > void *PrintHello(void *threadid) > { > printf("\n%d: Hello World!\n", threadid); > CreateThread(THREADS_IN_ONE_PROCESS); > pthread_exit(NULL); > } > > int main (int argc, char *argv[]) > { > CreateThread(THREADS_IN_ONE_PROCESS); > } > > The SEG fault happens after creating nearly 5000 threads. > and I use the default pthread.h coming w/ freeBSD 5.3 > #define PTHREAD_KEYS_MAX 256 > #define PTHREAD_STACK_MIN (1 << 22) > #define PTHREAD_THREADS_MAX ULONG_MAX > > > Any idea on what might happen? > > Many Thanks! > yan > _______________________________________________ > freebsd-hackers@freebsd.org mailing list > http://lists.freebsd.org/mailman/listinfo/freebsd-hackers > To unsubscribe, send any mail to "freebsd-hackers-unsubscribe@freebsd.org" -- Jose Hidalgo Herrera Corp. Hostarica