From owner-freebsd-current@FreeBSD.ORG Mon Aug 1 14:16:06 2011 Return-Path: Delivered-To: current@freebsd.org Received: from mx1.freebsd.org (mx1.freebsd.org [IPv6:2001:4f8:fff6::34]) by hub.freebsd.org (Postfix) with ESMTP id 0C4BF1065673 for ; Mon, 1 Aug 2011 14:16:06 +0000 (UTC) (envelope-from mdf356@gmail.com) Received: from mail-qy0-f175.google.com (mail-qy0-f175.google.com [209.85.216.175]) by mx1.freebsd.org (Postfix) with ESMTP id B880E8FC0A for ; Mon, 1 Aug 2011 14:16:05 +0000 (UTC) Received: by qyk30 with SMTP id 30so1125865qyk.13 for ; Mon, 01 Aug 2011 07:16:05 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=gamma; h=mime-version:sender:in-reply-to:references:date :x-google-sender-auth:message-id:subject:from:to:cc:content-type :content-transfer-encoding; bh=KJ2u3wQK+TM1XqOBTsXkSt3dyWUg9ArNqsaEBI+E1c4=; b=r8GNli6W6AQhDV3FhYc9ZE1ezMFsxj6yx6fyCa28KT+W0sPrWva8hX2RKSIPKjHVTR fdMtShow3BstmLrdgZkHOWXfPdsh1BUIMKnv0teLRp+btEqfV38rfzlpphDIhVYrSw7j lwMkGzegHOQw9tanDNpEvMWMioKlgs/lQR3gg= MIME-Version: 1.0 Received: by 10.229.26.212 with SMTP id f20mr1671012qcc.179.1312206441119; Mon, 01 Aug 2011 06:47:21 -0700 (PDT) Sender: mdf356@gmail.com Received: by 10.229.73.138 with HTTP; Mon, 1 Aug 2011 06:47:21 -0700 (PDT) In-Reply-To: References: Date: Mon, 1 Aug 2011 06:47:21 -0700 X-Google-Sender-Auth: c4FXwRm-l5I0Gmpekrb0LbRISlc Message-ID: From: mdf@FreeBSD.org To: Andrew Thompson Content-Type: text/plain; charset=ISO-8859-1 Content-Transfer-Encoding: quoted-printable Cc: "current@freebsd.org Current" Subject: Re: variable init X-BeenThere: freebsd-current@freebsd.org X-Mailman-Version: 2.1.5 Precedence: list List-Id: Discussions about the use of FreeBSD-current List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Mon, 01 Aug 2011 14:16:06 -0000 On Mon, Aug 1, 2011 at 12:09 AM, Andrew Thompson wrote: > Hi, > > Looking at, > > http://www.freebsd.org/cgi/query-pr.cgi?pr=3D159345 > > The lock is a global variable, declared as > > static struct mtx =A0 =A0 =A0 lagg_list_mtx; > > I would expect this to be zeroed memory, is this guaranteed? It depends. :-) The C standard mandates that this storage be zero. However, seeing as we're the operating system, it's our job to do it. For an application program the zero'd storage is zeroed by the loader. For the operating system, exactly when it's initialized is an architectural decision. I believe that the zeroed storage of FreeBSD is cleared by the boot loader before it transfers control to the operating system. (For reference, on AIX the storage is cleared by the virtual memory management code during bringup of the VMM leading to interesting bugs when some variables used in early boot weren't initialized). Cheers, matthew