D
Dan Pop
In said:All unixes I've seen use a flat memory model for user space applications.
How many Unices for the 8086 and 286 have you seen?
Dan
In said:All unixes I've seen use a flat memory model for user space applications.
In said:Pointers in C, no matter how they are represented by the
underlying hardware/architecture, always appear as a flat
address memory model.
In said:And somewhere around the time of 05/16/2004 09:41, the world stopped and
listened as Stephen L. contributed the following to humanity:
Ah, the flat memory model. That's exactly what I was looking for.
CBFalconer said::
... snip ...
That is just NOT so. That fact is at the root of the ban on
subtracting pointers that do not point within the same object. It
also the reason that most pointer comparisons can only be for
equal/not-equal.
He said "on a x86" and mentioned "Unix" in the Subject line, so he seems
to realize it's platform dependent.
It's probably not in the compiler manual -- the format of pointers (and
other data types) is typically dictated by the operating system's ABI.
Otherwise, you wouldn't be able to use applications compiled with a
different compiler than the system's libraries.
However, since there's more than one vendor of Unix for x86 platforms,
and they're not required to be binary-compatible with each other, the
answer may be specific to the particular version of Unix the OP is
using. Since he didn't say, we can't even give a good answer for this
in comp.unix.programmer.
glen herrmannsfeldt said:I used to think that large model would be a good way to
get past the 4GB limit on 32 bit processors. (Many IA32
processors have a 36 bit physical address bus but only a 32 bit
MMU.)
Now that Opteron and Athlon 64 prices are coming down, close
to $200 for the processor, one might just as well support that.
None. And I've neither touched AIX as someone else mentioned here.
None. And I've neither touched AIX as someone else mentioned here.
Victor said:: I used to think that large model would be a good way to
: get past the 4GB limit on 32 bit processors. (Many IA32
It is rather terrible way. I remeber days of DOS programming, it was
a pain to deal with segments and selectors. And it is also was awfully
slow. Intersegment calls was several times slower in 286 protected mode
that in real mode, not mentioning "short" calls.
: processors have a 36 bit physical address bus but only a 32 bit
: MMU.) Now that Opteron and Athlon 64 prices are coming down, close
: to $200 for the processor, one might just as well support that.
Now, Unixes already support flat 64-bit model on those processors.
Several Linux distributions are released, FreeBSD supports them too,
64-bit Solaris for x86-64 is on the way. So, better get rid of this
outdated 32-bit crap.
Isn't the linear address space still 32-bit even if you have a 48-bit
virtual address space and a 36-bit physical address space?
That's ideal, but there's a lot of existing CPUs out there that will be in
service for another decade. And, of course, Intel and AMD are still
shipping new 32-bit chips.
Don't forget SCO's XENIX; that was available for the 80286, IIRC.
Several mainstream OSes (including linux and freebsd, I think) use a
flat memory model.
Eric Sosman said:The ban also arises from the properties of pointer
arithmetic as defined by C: Subtracting two pointers (when
permitted) gives the number of instances of the pointed-to
type that lie between them. This is the flip side of what
happens when you add an integer to a pointer: Adding one
to a `double*' advances by the sizeof one double, not by
one byte.
So, consider
typedef char Buffer[527];
char *p = malloc(528); /* assume success */
Buffer *b1 = (Buffer*)p;
Buffer *b2 = (Buffer*)(p+1);
ptrdiff_t d = b2 - b1; /* bzzzt! */
`b1' and `b2' point to memory locations only one byte
apart, and one is not divisible by 527. The subtraction
is undefined, because there's no way to define it and
still maintain the properties of pointer arithmetic.
In said:And, I think, Microsoft made XENIX for the 8086. (One of my older UNIX
How did that work on a 16-bit chip without an MMU? (That is, how did it
differ from MS-DOS aside from the API/ABI and command shell being
different?)
And, I think, Microsoft made XENIX for the 8086. (One of my older UNIX
books mentions it, in a discussion of how far the *nix idea had gone by
the mid-80s.)
How did that work on a 16-bit chip without an MMU? (That is, how did it
differ from MS-DOS aside from the API/ABI and command shell being
different?)
and in
real mode any pointer with the same value of 16*segment+offset
points to the same byte, even if the pointers don't compare equal.
This is decidedly unlike a flat address space.
Ralmin said:Eric Sosman said:The ban also arises from the properties of pointer
arithmetic as defined by C: Subtracting two pointers (when
permitted) gives the number of instances of the pointed-to
type that lie between them. This is the flip side of what
happens when you add an integer to a pointer: Adding one
to a `double*' advances by the sizeof one double, not by
one byte.
So, consider
typedef char Buffer[527];
char *p = malloc(528); /* assume success */
Buffer *b1 = (Buffer*)p;
Buffer *b2 = (Buffer*)(p+1);
Is it possible for an array of char to have alignment requirements?
I would have expected the implicit division of 1 by 527 to always round down
to zero in practise.
It appears to produce zero on most of my
implementations to hand (lcc-win32, microsoft vc++, borland bcc32), but
surprisingly not on cygwin gcc, where it produces a ptrdiff_t value
of -2086359825. Weird.
>
<OT> Any explanations? </OT>
Want to reply to this thread or ask your own question?
You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.