Skip site navigation (1)Skip section navigation (2)
Date:      Mon, 1 Aug 2011 06:47:21 -0700
From:      mdf@FreeBSD.org
To:        Andrew Thompson <andy@fud.org.nz>
Cc:        "current@freebsd.org Current" <current@freebsd.org>
Subject:   Re: variable init
Message-ID:  <CAMBSHm_EZRdft%2B9DnC_7CBR=eO=1mWmXoCGgytKGs_oUBfdvcw@mail.gmail.com>
In-Reply-To: <CAFAOGNRN3e_9SyHU5yfRf-EhEWbWhpepCVQT-=n4LL-V44J1EQ@mail.gmail.com>
References:  <CAFAOGNRN3e_9SyHU5yfRf-EhEWbWhpepCVQT-=n4LL-V44J1EQ@mail.gmail.com>

next in thread | previous in thread | raw e-mail | index | archive | help
On Mon, Aug 1, 2011 at 12:09 AM, Andrew Thompson <andy@fud.org.nz> 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



Want to link to this message? Use this URL: <https://mail-archive.FreeBSD.org/cgi/mid.cgi?CAMBSHm_EZRdft%2B9DnC_7CBR=eO=1mWmXoCGgytKGs_oUBfdvcw>