From owner-freebsd-hackers Sun Jan 16 22:41:15 2000 Delivered-To: freebsd-hackers@freebsd.org Received: from mail.xmission.com (mail.xmission.com [198.60.22.22]) by hub.freebsd.org (Postfix) with ESMTP id 7094214DFF for ; Sun, 16 Jan 2000 22:41:13 -0800 (PST) (envelope-from wes@softweyr.com) Received: from [204.68.178.39] (helo=softweyr.com ident=wes) by mail.xmission.com with esmtp (Exim 3.03 #3) id 12A5qh-0002ue-00; Sun, 16 Jan 2000 23:41:12 -0700 Message-ID: <3882BA78.4EE522F1@softweyr.com> Date: Sun, 16 Jan 2000 23:45:12 -0700 From: Wes Peters Organization: Softweyr LLC X-Mailer: Mozilla 4.7 [en] (X11; U; FreeBSD 3.3-RELEASE i386) X-Accept-Language: en MIME-Version: 1.0 To: Jason Evans Cc: Alexander Litvin , hackers@FreeBSD.ORG Subject: Re: Preemptiveness of FreeBSD threads References: <20000116225044.C601@unknown.nowhere.org> <20000116220322.T302@sturm.canonware.com> Content-Type: text/plain; charset=us-ascii Content-Transfer-Encoding: 7bit Sender: owner-freebsd-hackers@FreeBSD.ORG Precedence: bulk X-Loop: FreeBSD.ORG 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 -- "Where am I, and what am I doing in this handbasket?" Wes Peters Softweyr LLC wes@softweyr.com http://softweyr.com/ To Unsubscribe: send mail to majordomo@FreeBSD.org with "unsubscribe freebsd-hackers" in the body of the message