From owner-freebsd-current Sun Aug 16 07:31:25 1998 Return-Path: Received: (from majordom@localhost) by hub.freebsd.org (8.8.8/8.8.8) id HAA16274 for freebsd-current-outgoing; Sun, 16 Aug 1998 07:31:25 -0700 (PDT) (envelope-from owner-freebsd-current@FreeBSD.ORG) Received: from ns.tar.com (ns.tar.com [204.95.187.2]) by hub.freebsd.org (8.8.8/8.8.8) with ESMTP id HAA16265 for ; Sun, 16 Aug 1998 07:31:18 -0700 (PDT) (envelope-from lists@tar.com) Received: from ppro.tar.com (ppro.tar.com [204.95.187.9]) by ns.tar.com (8.8.8/8.8.7) with SMTP id JAA23187; Sun, 16 Aug 1998 09:30:25 -0500 (CDT) Message-Id: <199808161430.JAA23187@ns.tar.com> From: "Richard Seaman, Jr." To: "John Birrell" , "Brian Cully" , "Daniel Eischen" Cc: "freebsd-current@FreeBSD.ORG" Date: Sun, 16 Aug 98 09:30:25 -0500 Reply-To: "Richard Seaman, Jr." X-Mailer: PMMail 1.92 For OS/2 MIME-Version: 1.0 Content-Type: text/plain; charset="us-ascii" Content-Transfer-Encoding: 7bit Subject: Bug in pthread scheduler? (Was pthreads woes revisited) Sender: owner-freebsd-current@FreeBSD.ORG Precedence: bulk X-Loop: FreeBSD.ORG On Fri, 7 Aug 1998 10:06:43 -0400, Brian Cully wrote: >On Thu, Aug 06, 1998 at 05:13:02PM -0400, Daniel Eischen wrote: >> You're not adding the pthread_yield() call that I added after >> the pthread_cond_signal(). Your program is bogus because there >> is no guarantee that the main thread will release the CPU in >> order for the other task to run. You need to perform some >> sort of blocking operation after the pthread_cond_signal. I >> chose to use pthread_yield, although sleep would work just as >> well. > >Do'h! I missed that. That did make the sample program work, so >it looks like the error was mine all along, sorry for troubling >everybody. Actually, its not at all clear to me that you need the pthread_yield() call. In looking at the pthread scheduler, it appears that the scheduler should preempt (with in the context of the process) the main thread periodically. It also appears that there might be a bug in the scheduler code. Try the following diff and see what you get. *** uthread_kern.c Sun Aug 16 09:07:14 1998 --- uthread_kern.c.orig Sun Aug 16 09:06:17 1998 *************** *** 661,667 **** * Do a sigreturn to restart the thread that * was interrupted by a signal: */ - _thread_kern_in_sched = 0; _thread_sys_sigreturn(&_thread_run->saved_sigcontext); } else /* --- 661,666 ---- To Unsubscribe: send mail to majordomo@FreeBSD.org with "unsubscribe freebsd-current" in the body of the message