From owner-freebsd-hackers@FreeBSD.ORG Fri Sep 25 13:57:02 2009 Return-Path: Delivered-To: hackers@freebsd.org Received: from mx1.freebsd.org (mx1.freebsd.org [IPv6:2001:4f8:fff6::34]) by hub.freebsd.org (Postfix) with ESMTP id 9E3F11065696; Fri, 25 Sep 2009 13:57:02 +0000 (UTC) (envelope-from rysto32@gmail.com) Received: from ey-out-2122.google.com (ey-out-2122.google.com [74.125.78.26]) by mx1.freebsd.org (Postfix) with ESMTP id B77648FC22; Fri, 25 Sep 2009 13:57:01 +0000 (UTC) Received: by ey-out-2122.google.com with SMTP id 4so580931eyf.9 for ; Fri, 25 Sep 2009 06:57:00 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=gamma; h=domainkey-signature:mime-version:received:in-reply-to:references :date:message-id:subject:from:to:cc:content-type; bh=P6UGGiNWVZfu4dvd0/K1GalmAkScZT4m4UnrU/i52+8=; b=NsrD+aXeJgvqVsNnvPxiF3Zrip9pfszLFjXkbdJs2MW3UugC2nvGh9C20idLRDaHhD 8FN6AQPQvDfjKGuvCIOmYMb0xCoFVCpsI5pdVxktMs/qIEf64zU075XGnPqQkFC7jdvS u5Q0213N835rHyn6d/nmSgj1mdgebmbZFl1F4= DomainKey-Signature: a=rsa-sha1; c=nofws; d=gmail.com; s=gamma; h=mime-version:in-reply-to:references:date:message-id:subject:from:to :cc:content-type; b=mcHF9nxLhSF9+Bpxh5GcvGSKDIj3Vn9bOs9AIlhe7idoBnDYpTR9jjnx0Q8cl5kHwZ Ts45MOE6AbWa5hp90Tx9idloofkLMoutOrRkf5IgWEgJqAIhZTgi3fbftzOM4AAvk8cN 4vgG7emQLMHBsVBNpTR7odWYAl2XOZrRbrmYk= MIME-Version: 1.0 Received: by 10.211.161.26 with SMTP id n26mr181363ebo.74.1253885434914; Fri, 25 Sep 2009 06:30:34 -0700 (PDT) In-Reply-To: <1253877997.2031.2627.camel@balrog.2hip.net> References: <20090924224935.GW473@gandalf.sssup.it> <1253877997.2031.2627.camel@balrog.2hip.net> Date: Fri, 25 Sep 2009 09:30:34 -0400 Message-ID: From: Ryan Stone To: Robert Noland Content-Type: text/plain; charset=ISO-8859-1 Cc: attilio@freebsd.org, hackers@freebsd.org, Fabio Checconi Subject: Re: sx locks and memory barriers 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: Fri, 25 Sep 2009 13:57:02 -0000 The code that Fabio proposes looks like this: sx_slock(&data->lock); if (data->buffer) a = *data->buffer; sx_sunlock(&data->lock); This point is that without a memory barrier on the unlock, the CPU is free to reorder the instructions into the order is his message.