comp.lang.ada
 help / color / mirror / Atom feed
From: Robert A Duff <bobduff@shell01.TheWorld.com>
Subject: Re: Counting Elements figured out.
Date: 02 Dec 2005 18:09:58 -0500
Date: 2005-12-02T18:09:58-05:00	[thread overview]
Message-ID: <wcc3blbt7sp.fsf@shell01.TheWorld.com> (raw)
In-Reply-To: pan.2005.11.30.23.15.25.917461@nowhere.net

Freejack <freejack@nowhere.net> writes:

> Aha. I gotcha. I suppose I should take that into account when mapping the
> storage space into my process. I just tested it out. It works when the
> compiler does it's malloc() allocations, but segfaults on an mmaped()
> region. So the length of the region I map should be
> Size_In_Storage_Elements + 1, yes? And then use the " - 1 " on allocations
> from that region?

I don't really understand the above, but it doesn't look right.

Anyway, mmap requires page-alignment, right?  That is, you can't mmap
100 bytes; you have to round it up to 2**12 or 2**13 bytes or some
such.

> I suppose I should have two Region types. One where Storage blocks are
> exact multiples of Storage_Unit, and one that handles truncated Sizes.

I don't think that makes sense.  Allocation is always done in integer
numbers of storage units (storage elements).  A storage pool type never
has to deal with fractional storage elements.  That is, on a normaly
8-bit-byte-addressable machine, Allocate will never be asked to allocate
3 bits, or 67 bits -- it doesn't get sizes in bits at all.

You have to deal with different alignments, though.  The required
alignment is passed in to Allocate.  It should make sure that the
address returned is aligned to that boundary, or else it should raise an
exception for unsupported alignments.  Alignment is also in terms of
storage units/elements, not bits.  The simplest thing is to always align
to the most stringent natural alignment required by the hardware,
which is usually Long_Float'Alignment, which is usually 4 or 8.

>... Oh
> gawd, about two dozen possible schemes just jumped into my head all at
> once.
> 
> Heh. The wonderful world of memory managment.

- Bob



  parent reply	other threads:[~2005-12-02 23:09 UTC|newest]

Thread overview: 4+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
     [not found] <pan.2005.11.30.01.47.41.83657@nowhere.net>
2005-11-25 16:29 ` Counting Elements figured out David C. Hoos, Sr.
     [not found]   ` <pan.2005.11.30.23.15.25.917461@nowhere.net>
2005-12-02 23:09     ` Robert A Duff [this message]
2005-12-03 22:04       ` Gisle Sælensminde
2005-12-03 22:21         ` Robert A Duff
replies disabled

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox