From owner-cvs-sys Thu Oct 10 03:02:00 1996 Return-Path: owner-cvs-sys Received: (from root@localhost) by freefall.freebsd.org (8.7.5/8.7.3) id DAA05964 for cvs-sys-outgoing; Thu, 10 Oct 1996 03:02:00 -0700 (PDT) Received: from godzilla.zeta.org.au (godzilla.zeta.org.au [203.2.228.19]) by freefall.freebsd.org (8.7.5/8.7.3) with ESMTP id DAA05951; Thu, 10 Oct 1996 03:01:52 -0700 (PDT) Received: (from bde@localhost) by godzilla.zeta.org.au (8.7.6/8.6.9) id TAA14674; Thu, 10 Oct 1996 19:58:39 +1000 Date: Thu, 10 Oct 1996 19:58:39 +1000 From: Bruce Evans Message-Id: <199610100958.TAA14674@godzilla.zeta.org.au> To: bde@zeta.org.au, kato@eclogite.eps.nagoya-u.ac.jp Subject: Re: cvs commit: src/sys/i386/isa/sound sb.h src/sys/pc98/conf GENERIC98 Makefile.pc98 options.pc98 src/sys/pc98/i386 locore.s machdep.c pmap.c userconfig.c vm_machdep.c src/sys/pc98/pc98/sound ad1848.c os.h pas2_pcm.c sb16_dsp.c ulaw.h sb.h src/sys/pc98/boot/biosboot boot.c boot.h disk.c io.c sys.c table.c src/sys/pc98/pc98 atcompat_diskslice.c clock.c diskslice_machdep.c if_ed.c if_ed98.h if_fe.c npx.c pc98.c pc98.h pc98_machdep.c pc98_machdep.h pcaudio.c random_machdep.c sbic55.c sbic55.c.new sio.c syscons.c syscons.h wd.c Cc: asami@freefall.freebsd.org, cvs-all@freefall.freebsd.org, CVS-committers@freefall.freebsd.org, cvs-sys@freefall.freebsd.org Sender: owner-cvs-sys@FreeBSD.ORG X-Loop: FreeBSD.org Precedence: bulk >> > (7) Do not expect bss to be zero-allocated: >> > >> > pc98/pc98/pc98.c >> >> This should be expected. > >I think kernel is expected to initialize bss, but programer should not >expect this because I consider bss to non initialized data. The kernel is written in C (sort of). In C, all non-local objects that aren't explicitly initialized are guaranteed to be initialized as if they had 0 assigned to the scalars in them. This may result in a nonzero bit pattern in memory on machines where the NULL pointer is not all-bits-0 or floating point 0's aren't all-bits-0. The i386 kernel guarantees this by initializing the bss to all-bits-0. It's simplest to depend on ordinary C features if possible. However, there are reasons for statically initializing data. E.g., it increases locality. The linker scatters common variables all over the place, so there is little chance that related common variables end up in the same cache line, and some chance that they are allocated to locations that cause cache collisions. The compiler and linker happen allocate statically initialized data in the same order as it is defined (even to 0), so static initialization can be used to get a better layout. This is probably worth doing (only) for the most heavily accessed variables. Bruce