From owner-freebsd-hackers Sun Jan 16 23:13: 7 2000 Delivered-To: freebsd-hackers@freebsd.org Received: from canonware.com (canonware.com [207.20.242.18]) by hub.freebsd.org (Postfix) with SMTP id 344EB14C1A for ; Sun, 16 Jan 2000 23:13:05 -0800 (PST) (envelope-from jasone@canonware.com) Received: (qmail 27320 invoked by uid 1001); 17 Jan 2000 07:12:10 -0000 Date: Sun, 16 Jan 2000 23:12:10 -0800 From: Jason Evans To: Wes Peters Cc: hackers@FreeBSD.ORG Subject: Re: Preemptiveness of FreeBSD threads Message-ID: <20000116231210.U302@sturm.canonware.com> References: <20000116225044.C601@unknown.nowhere.org> <20000116220322.T302@sturm.canonware.com> <3882BA78.4EE522F1@softweyr.com> Mime-Version: 1.0 Content-Type: text/plain; charset=us-ascii X-Mailer: Mutt 1.0i In-Reply-To: <3882BA78.4EE522F1@softweyr.com>; from wes@softweyr.com on Sun, Jan 16, 2000 at 11:45:12PM -0700 Sender: owner-freebsd-hackers@FreeBSD.ORG Precedence: bulk X-Loop: FreeBSD.ORG On Sun, Jan 16, 2000 at 11:45:12PM -0700, Wes Peters wrote: > Jason Evans wrote: > > > > You don't mention how long you run the program for, so I'm assuming that > > the runtime must be quite short for you to be seeing the results that > > concerned you. All tests that I ran showed non-zero counters for all > > threads if the program ran for more than 1.5 seconds. > > wes@homer$ time ./threadtest > ^C > Thread 0x00: 0 > Thread 0x01: 0 > Thread 0x02: 0 > Thread 0x03: 0 > Thread 0x04: 0 > Thread 0x05: 0 > Thread 0x06: 0 > Thread 0x07: 0 > Thread 0x08: 0 > Thread 0x09: 0 > Thread 0x0a: 223277111 > > real 0m5.403s > user 0m5.256s > sys 0m0.001s > wes@homer$ uname -a > FreeBSD homer 3.3-RELEASE FreeBSD 3.3-RELEASE #4: Thu Dec 23 14:45:28 MST 1999 rootb@homer:/usr/src/sys/compile/HOMER i386 > > Adding a sched_yield() in the main function before the call to start_my_thread > seems to solve the problem: > > wes@homer$ time ./threadtest > ^C > Thread 0x00: 20767331 > Thread 0x01: 25057587 > Thread 0x02: 21035219 > Thread 0x03: 18914176 > Thread 0x04: 8465648 > Thread 0x05: 16969167 > Thread 0x06: 16848430 > Thread 0x07: 16359150 > Thread 0x08: 16933300 > Thread 0x09: 16607575 > Thread 0x0a: 12583271 > > real 0m4.585s > user 0m4.476s > sys 0m0.011s Okay, so much for that theory. =) Also, I finally saw the reported behaviour twice, though when I recompiled, it went away. This could be hard to track down... Jason To Unsubscribe: send mail to majordomo@FreeBSD.org with "unsubscribe freebsd-hackers" in the body of the message