Return-Path: X-Original-To: apmail-zookeeper-user-archive@www.apache.org Delivered-To: apmail-zookeeper-user-archive@www.apache.org Received: from mail.apache.org (hermes.apache.org [140.211.11.3]) by minotaur.apache.org (Postfix) with SMTP id 3D6514178 for ; Mon, 9 May 2011 04:11:48 +0000 (UTC) Received: (qmail 28775 invoked by uid 500); 9 May 2011 04:11:48 -0000 Delivered-To: apmail-zookeeper-user-archive@zookeeper.apache.org Received: (qmail 28301 invoked by uid 500); 9 May 2011 04:11:46 -0000 Mailing-List: contact user-help@zookeeper.apache.org; run by ezmlm Precedence: bulk List-Help: List-Unsubscribe: List-Post: List-Id: Reply-To: user@zookeeper.apache.org Delivered-To: mailing list user@zookeeper.apache.org Received: (qmail 28287 invoked by uid 99); 9 May 2011 04:11:43 -0000 Received: from athena.apache.org (HELO athena.apache.org) (140.211.11.136) by apache.org (qpsmtpd/0.29) with ESMTP; Mon, 09 May 2011 04:11:43 +0000 X-ASF-Spam-Status: No, hits=1.5 required=5.0 tests=FREEMAIL_FROM,HTML_MESSAGE,RCVD_IN_DNSWL_LOW,RFC_ABUSE_POST,SPF_PASS,T_TO_NO_BRKTS_FREEMAIL X-Spam-Check-By: apache.org Received-SPF: pass (athena.apache.org: domain of ted.dunning@gmail.com designates 209.85.220.170 as permitted sender) Received: from [209.85.220.170] (HELO mail-vx0-f170.google.com) (209.85.220.170) by apache.org (qpsmtpd/0.29) with ESMTP; Mon, 09 May 2011 04:11:37 +0000 Received: by vxb40 with SMTP id 40so7925135vxb.15 for ; Sun, 08 May 2011 21:11:16 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=gamma; h=domainkey-signature:mime-version:in-reply-to:references:from:date :message-id:subject:to:content-type; bh=RNGUMqQE1OBXcrPYJQKNipN99STOih4iZNjFZ4IsTx8=; b=wm2IY31QIYuSz7QysQ3B2Jd69EOVmh5RUyFLiiVKX7b7ArM26tfztY40Rh9u7mlWd9 gFuTGMogvJ6gUS6Rj4w0qOsiXC6l2mJnSG1/wqgII64b2/Ev55L2eKrOc6GZuFFW/NWq MR9cmOeE9wlHKvcSbVxgjfCfNK1W1v1RlgVQg= DomainKey-Signature: a=rsa-sha1; c=nofws; d=gmail.com; s=gamma; h=mime-version:in-reply-to:references:from:date:message-id:subject:to :content-type; b=vWCzOLgHC03HZqGR5kcmfYxyiMjJjX54vyTgEr7v4Sz+M0oS8/sOnI2xE4mYZWwqtK dHMRDLW8EKjHpfL4O3XVO3cjoziCCA8Frcnv9vSEzRBKKFnHIFro0MJsb75E/wOLo750 Zy69DBYl0v6DgLMRJmh3fwSuHv4FiJSDYvRFM= Received: by 10.52.176.10 with SMTP id ce10mr163274vdc.280.1304914276092; Sun, 08 May 2011 21:11:16 -0700 (PDT) MIME-Version: 1.0 Received: by 10.52.116.42 with HTTP; Sun, 8 May 2011 21:10:56 -0700 (PDT) In-Reply-To: References: <4DC6F9AB.6000009@gmail.com> From: Ted Dunning Date: Sun, 8 May 2011 21:10:56 -0700 Message-ID: Subject: Re: Barrier Tutorial Possible Deadlock To: user@zookeeper.apache.org Content-Type: multipart/alternative; boundary=bcaec51a8184e38aee04a2d007bc --bcaec51a8184e38aee04a2d007bc Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: quoted-printable Justin, I think you are correct that there is a bug in the recipe and I think that Xing has the core of the solution. One solution is for the contents of the root to be an enum with the following starts: STOP RUN The initial value should be STOP. The enter method should be changed so that it gets the children list as before and checks the size. If the size is large enough, the code should set the value of the root to be RUN. If the size is not large enough, the value of the root should be interrogated and if it is RUN, the program should continue. If the size is too small and the value is STOP, then the code should wait as before. The leave method should work the same as before except that when the number of children reaches zero, the state should be set to STOP. Note that this algorithm is robust to fast processes on the start side. Th= e details of how processes that arrive as other processes are leaving the Barrier is somewhat debatable. It might be preferable to add a third enum state (LEAVING) to prevent additional processes from entering as soon as th= e first process starts to leave the Barrier. The first process to start leaving the Barrier would set the enum to LEAVING and the last process to finish leaving the Barrier would set it to STOP. Doing this would require that processes also watch the root contents as well as children, but avoids the problem of processes entering the barrier while the rest are leaving th= e barrier. On Sun, May 8, 2011 at 8:13 PM, =E9=82=A2=E8=BF=AA=E4=BE=83 wrote: > Letting Process 2 leaves something on ZK (create a file, for > example) before it starts to compute, and letting others watch that thing= . > --bcaec51a8184e38aee04a2d007bc--