Skip site navigation (1)Skip section navigation (2)
Date:      Tue, 13 Jan 1998 22:30:18 -0600 (CST)
From:      Joel Ray Holveck <joelh@gnu.org>
To:        freebsd-hackers@FreeBSD.ORG
Subject:   Re: sharable static arrays?
Message-ID:  <199801140430.WAA03879@detlev.UUCP>
In-Reply-To: <19980112194053.29382@flix.net> (message from Chrisy Luke on Mon, 12 Jan 1998 19:40:53 %2B0000)
References:  <19980112112455.48744@flix.net> <Pine.BSF.3.95q.980112105953.9226C-100000@misery.sdf.com> <19980112194053.29382@flix.net>

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

>>>> Are static arrays shared across multiple invocations of a program?
>>> Not intrinsicly. You'll have to either use SYS-V style shared
>>> memory (options SYSVSHM SYSVSEM SYSVMSG in a kernel config and
>>> shmget(2) etc) or use BSD style mapped memory (mmap(2)).
>> Remember these are _static_ arrays, which mean they are directly coded
> He said static, not const. There's a difference. Static data can be
> modified, it's just by inference hidden from higher scopes.

My apologies, I was meaning 'static' as opposed to 'dynamic'.  I
should have said 'const'.

> Static memory is shared (it's setup by the C startup module) in so
> far as the initial state is the same. Any changes will not be seen
> across multiple invokations. For that, you need shared memory of
> some nature.

So it's originally mapped in as shared, but copy-on-write, then?  Does
this only apply to vars declared static, or does it also apply to
global vars not declared static?

> In this case, of course, the area should be marked volatile... :-)

Some might argue that several of my entire programs should be marked
volatile... :-)

Thanks,
joelh

-- 
Joel Ray Holveck - joelh@gnu.org - http://www.wp.com/piquan
   Fourth law of programming:
   Anything that can go wrong wi
sendmail: segmentation violation - core dumped





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