Return-Path: william@bourbon.usc.edu Delivery-Date: Sun Sep 21 08:57:14 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 m8LFvEEF012564 for ; Sun, 21 Sep 2008 08:57:14 -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 m8LFxO5R000642 for ; Sun, 21 Sep 2008 08:59:24 -0700 Message-Id: <200809211559.m8LFxO5R000642@bourbon.usc.edu> To: cs551@merlot.usc.edu Subject: Re: doubt regarding signal and wait Date: Sun, 21 Sep 2008 08:59:23 -0700 From: Bill Cheng Someone wrote: > on the page 82 of "pthreads programming" it says, > "If all waiting threads are of the same priority, they are released in > a first-in first-out order for each pthread_cond_signal call that's > issued." > > So I guess it should be in FIFO fashion. (I agree that we should write > code to make sure that it works under any order though.) Hmm... That's not how I remembered it! Clearly, I was wrong. Thanks for pointing out what's in the book! But since the book is really not the pthread spec, I would not be so sure if Solaris implements everything according to the book. -- Bill Cheng // bill.cheng@usc.edu On Sat, Sep 20, 2008 at 8:32 PM, Bill Cheng wrote: > Someone wrote: > > > In what fashion does the signal wake up the waiting thread.Is it FIFO or is > > it OS Dependent ? > > It's unspecified. So, it may be OS dependent. Or it may > depend on other stuff that you have no control of. > > > In my case, > > Server 1 is started first and than Server 2. > > Since initially Queue is empty, both will sleep for some customer to arrive > > in the Queue. > > > > But Server 2 (and not Server 1) gets chance to serve the first Customer. > > You should write code to make sure that it works under > any order since you cannot predict which thread will > wake up first. > -- > Bill Cheng // bill.cheng@usc.edu