Return-Path: william@bourbon.usc.edu Delivery-Date: Thu Sep 25 21:47:39 2008 X-Spam-Checker-Version: SpamAssassin 3.2.3 (2007-08-08) on merlot.usc.edu X-Spam-Level: X-Spam-Status: No, score=-2.3 required=5.0 tests=AWL,BAYES_00 autolearn=ham version=3.2.3 Received: from bourbon.usc.edu (bourbon.usc.edu [128.125.9.75]) by merlot.usc.edu (8.14.1/8.14.1) with ESMTP id m8Q4ldEo022435 for ; Thu, 25 Sep 2008 21:47:39 -0700 Received: from bourbon.usc.edu (localhost.localdomain [127.0.0.1]) by bourbon.usc.edu (8.14.2/8.14.1) with ESMTP id m8Q4osMj001287 for ; Thu, 25 Sep 2008 21:50:54 -0700 Message-Id: <200809260450.m8Q4osMj001287@bourbon.usc.edu> To: cs551@merlot.usc.edu Subject: Re: Discrepancy in the book Date: Thu, 25 Sep 2008 21:50:54 -0700 From: Bill Cheng Someone wrote: > pp 81 of "pthread programming" says, "The pthread_cond_signal function > wakes up only one of the potentially many threads waiting on the > condition; the pthread_cond_broadcast function awaken all of them." > > I designed the program accordingly, but later I found that > pthread_cond_signal seemed to wake up more than one thread at a time. > > And then I noticed on the man page of Solaris (and Linux also) that > "The pthread_cond_signal() call unblocks at least one of the threads > that are blocked ...." > > I think the book is based on some other implementation of POSIX thread > or a bit out-dated. The book was published in 1996. So, it's possible that it's out-dated. This is why I've mentioned in lectures that you should check out the man pages on Solaris. Although I have to say that I'm a bit surprised that it says "at least one of the threads that are blocked"! Given the way we do , it's always best to wake up every blocked thread anyway! -- Bill Cheng // bill.cheng@usc.edu