Date: Sun, 16 Aug 98 09:30:25 -0500 From: "Richard Seaman, Jr." <lists@tar.com> To: "John Birrell" <jb@cimlogic.com.au>, "Brian Cully" <shmit@kublai.com>, "Daniel Eischen" <eischen@vigrid.com> Cc: "freebsd-current@FreeBSD.ORG" <freebsd-current@FreeBSD.ORG> Subject: Bug in pthread scheduler? (Was pthreads woes revisited) Message-ID: <199808161430.JAA23187@ns.tar.com>
next in thread | raw e-mail | index | archive | help
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
Want to link to this message? Use this URL: <https://mail-archive.FreeBSD.org/cgi/mid.cgi?199808161430.JAA23187>