Return-Path: william@bourbon.usc.edu Delivery-Date: Sat Sep 20 20:30:54 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 m8L3UsWN002112 for ; Sat, 20 Sep 2008 20:30:54 -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 m8L3WuhD020170 for ; Sat, 20 Sep 2008 20:32:56 -0700 Message-Id: <200809210332.m8L3WuhD020170@bourbon.usc.edu> To: cs551@merlot.usc.edu Subject: Re: doubt regarding signal and wait Date: Sat, 20 Sep 2008 20:32:56 -0700 From: Bill Cheng 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