Skip site navigation (1)Skip section navigation (2)
Date:      Thu, 10 Oct 1996 19:58:39 +1000
From:      Bruce Evans <bde@zeta.org.au>
To:        bde@zeta.org.au, kato@eclogite.eps.nagoya-u.ac.jp
Cc:        asami@freefall.freebsd.org, cvs-all@freefall.freebsd.org, CVS-committers@freefall.freebsd.org, cvs-sys@freefall.freebsd.org
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
Message-ID:  <199610100958.TAA14674@godzilla.zeta.org.au>

next in thread | raw e-mail | index | archive | help

>> >  (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



Want to link to this message? Use this URL: <https://mail-archive.FreeBSD.org/cgi/mid.cgi?199610100958.TAA14674>