httpd-dev mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From Brian Clapper <...@WillsCreek.COM>
Subject Re: SYSV Shared Memory (Was: Re: vote status)
Date Mon, 19 Feb 1996 19:13:10 GMT
>>>>> "Jim" == Jim Jagielski <> writes:

Jim> Robert S. Thau wrote:
>> My crude solution at the time was to malloc(1000000), then shmat(), then
>> free(). Not all that suitable really.

One solution I've used in the past, when on "normal" System V boxes, is
this one:

1. Use getrlimit(2) with the RLIMIT_DATA parameter (or ulimit(2) on old
   System V systems) to determine the maximum allowed size of the process.

2. Use sbrk(0) to determine the current "break" address.

3. Determine how much shared memory you need.

4. Do the math to determine the starting address of the shared memory
   segment such that it:

        a) ends up at the maximum address such that the end of the shared
           memory segment doesn't exceed the RLIMIT_DATA value; and
        b) is aligned on a word boundary, just to be safe.

5. Place the shared memory segment at the calculated address, allowing
   plenty of room "in between" for malloc'd data.

That scheme worked fine on the System Vs I tried it on.  I haven't had
occasion to try it on Linux or BSD systems with the System V shared memory
facilities, though.  It's simple enough to test.  If I can make time to do
so, I will.  If you're in a hurry, you might not want to wait for me,
though; I'm kind of swamped right now...
Brian Clapper ....................... bmc@WillsCreek.COM -or- ......... PGP public key available on request
Whatever became of Strange de Jim?  Well, he found a substitute for
cocaine: "You cover Q-tips with sandpaper and ram them up your nostrils
as far as they will go.  Then you sniff talcum powder while shredding
hundred dollar bills."
        -- Herb Caen

View raw message