From owner-freebsd-hackers@FreeBSD.ORG Thu Jul 17 17:42:34 2008 Return-Path: Delivered-To: freebsd-hackers@freebsd.org Received: from mx1.freebsd.org (mx1.freebsd.org [IPv6:2001:4f8:fff6::34]) by hub.freebsd.org (Postfix) with ESMTP id B75901065673 for ; Thu, 17 Jul 2008 17:42:34 +0000 (UTC) (envelope-from ioplex@gmail.com) Received: from nf-out-0910.google.com (nf-out-0910.google.com [64.233.182.185]) by mx1.freebsd.org (Postfix) with ESMTP id 4B8FC8FC19 for ; Thu, 17 Jul 2008 17:42:33 +0000 (UTC) (envelope-from ioplex@gmail.com) Received: by nf-out-0910.google.com with SMTP id h3so9144nfh.33 for ; Thu, 17 Jul 2008 10:42:32 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=gamma; h=domainkey-signature:received:received:message-id:date:from:to :subject:cc:in-reply-to:mime-version:content-type :content-transfer-encoding:content-disposition:references; bh=nPWUtyA0sBGfAbkIGJTjmlSuL18lRr5FmhoumJnpQgk=; b=kL4JZUxxRRBiXa7hEcxdnQTyIRxkzYwb9ctLJpi8oO6dR2TvDrPxjCOatburdiC9P8 Rdprk1NkYNlmVB3eRutWXI9hzD2bhEZr7CcaRZn9HTdfmPFB63a5LL3KUveIueU0nHgN bT0Oyr9niWqo0T3yJKiyW5OoOJ02j4UKYnqiw= DomainKey-Signature: a=rsa-sha1; c=nofws; d=gmail.com; s=gamma; h=message-id:date:from:to:subject:cc:in-reply-to:mime-version :content-type:content-transfer-encoding:content-disposition :references; b=t1/wahJMtu6t6hJHvhnBxNK7urQB1vdpbh2DIAHF0A0XU31GExMGseOaZX36YkGf1c 3O3D/PCDI5Yj8XHJnQZYuPPPi0UKJd82X7zqN61y9AKHsMRM28ydiWPIC1nH9z2pS0A9 Qjw/XRYO4Xcy7/NokiVplQ+ah8wLDuIT67AmY= Received: by 10.210.25.20 with SMTP id 20mr1366686eby.46.1216316551894; Thu, 17 Jul 2008 10:42:31 -0700 (PDT) Received: by 10.210.139.1 with HTTP; Thu, 17 Jul 2008 10:42:31 -0700 (PDT) Message-ID: <78c6bd860807171042o54627c78nfcc0c19717b75f1e@mail.gmail.com> Date: Thu, 17 Jul 2008 13:42:31 -0400 From: "Michael B Allen" To: "John Baldwin" In-Reply-To: <200807171005.53148.jhb@freebsd.org> MIME-Version: 1.0 Content-Type: text/plain; charset=ISO-8859-1 Content-Transfer-Encoding: 7bit Content-Disposition: inline References: <78c6bd860807121611w4f6ab44brbebfffea9929682a@mail.gmail.com> <200807171005.53148.jhb@freebsd.org> Cc: freebsd-hackers@freebsd.org Subject: Re: Pls sanity check my semtimedop(2) implementation X-BeenThere: freebsd-hackers@freebsd.org X-Mailman-Version: 2.1.5 Precedence: list List-Id: Technical Discussions relating to FreeBSD List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Thu, 17 Jul 2008 17:42:34 -0000 On Thu, Jul 17, 2008 at 10:05 AM, John Baldwin wrote: > On Saturday 12 July 2008 07:11:26 pm Michael B Allen wrote: >> Hi, >> >> Below is a semtimedop(2) implementation that I'm using for FreeBSD. I >> was hoping someone could look it over and tell me if they think the >> implementation is sound. >> >> The code seems to work ok but when stressing the FreeBSD build of my app >> I have managed to provoke errors related to concurrency (usually when a >> SIGALRM goes off). The Linux build works flawlessesly so I'm wondering >> about this one critical function that is different. >> >> Do you think it would make any difference if I used >> ITIMER_VIRTUAL / SIGVTALRM instead of ITIMER_REAL / SIGALRM? >> >> Or perhaps I should be using a different implementation entirely? > > What specific races are you seeing? The timer is firing too early, too late? It's very difficult to tell. I can only trigger the issue very occasionally running my torture test such that any diagnostic logging changes the results. And at this point I'm not sure my semtimedop implementation is responsible. I have not seen the issue since fixing the race pointed out by Mikko (although I have not tried very hard to provoke it). For now, I'm satisfied since I do not think the issue will be triggered in the wild. I hate to use signals for anything but as much as I try, there's just no other way to implement semtimedop within a single largely self-contained function. In the future I will likely use another process in the application that uses select(2) as an "event service" to post on semaphores after a certain time period. Unfortunately, right now, that service ultimately calls semtimedop so I'll save it for a rainy day. Although if you implemented semtimedop(2) into the FreeBSD API that would work too :-) Thanks, Mike -- Michael B Allen PHP Active Directory SPNEGO SSO http://www.ioplex.com/