In article <1148638085.431124.221190
@j73g2000cwa.googlegroups.com>,
vikram.sutar@gmail.com
says...[color=blue]
> Hi
> As you said we have 64 bit pointers..as far as I know for 32 bit
> systems we have 32 bit sized pointers.If there are any 64 bit pointers
> I really dont know about that. I am working with windows 2000 under
> microsoft C++ compiler version 6.0.[/color]
Under Win32, you use only 32 bit of a pointer -- but the
processor (Intel/AMD x86) actually requires 48-bits. The
48 bits consists of a 16-bit segment and a 32-bit offset.
In Win32, the segments are fixed, and all you work with
are offsets.
Nonetheless, if somebody wanted to, they could perfectly
well use multiple segments. In that case, they create a
"descriptor" for a segment that specifies (among other
things) the maximum offset legal for that segment (i.e.
the size of the memory block it refers to). The usual
Win32 segments are all set to a size of 4 GB, but that's
not required in general -- under a different system, you
could set them to the actual sizes of the memory blocks
they referred to.
[color=blue]
> for storing a size of (large)object , I need more bits from pointer
> variable. So what if size is too large. As sizeof operator returns size
> (size_t) is an unsigned integer. More the size more the bits I need !
> Please let me know if there are any misunderstandings...[/color]
There are quite a few ways of getting around this
problem. One is outlined above -- associate some data
with the pointer, but don't make it part of the pointer
itself. Another is to limit your selection of sizes. For
example, many memory allocators round the size of any
allocation to the next larger power of 2. In this case,
you really don't need to store the size of the
allocation, but instead just the base 2 logarithm of the
size. For a 64-bit system, that means the maximum size
you need to store is 64 -- which only requires 6 bits.
Most 64-bit systems only really use around 48 bits (or
less) for actual addressing. That leaves 16 bits (or
more) in the pointer that can be used to hold other data,
such as sizes, types, etc.
--
Later,
Jerry.
The universe is a figment of its own imagination.