Article View: net.lang.c
Article #9650Re: Microport and SCO Xenix Memory Managment Problems
From: Tim Smith
Date: Sat, 25 Oct 1986 04:41
Date: Sat, 25 Oct 1986 04:41
49 lines
2098 bytes
2098 bytes
sbrk has to behave funny because of program that assume a linear
address space. Many program that want N bytes do the following:
char * ptr;
ptr = sbrk(0);
brk(ptr+N);
To make these work correctly, sbrk(0) has to return the start of
the next segment.
For example, here is how brk and sbrk work on the AT&T pc6300+ (
which is a good indication of how AT&T thinks things should work
on 80286 based machines )
( all byte counts and addresses are rounded to a multiple
of 512 )
In small model, everything looks like a normal unix system
In large model,
sbrk(0) returns start of next data segment
sbrk(N) N > 0 allocates N bytes from next data segment
sbrk(N) N < 0 does this:
N = -N
while ( N >= size of last segment )
N = N - size of last segment
remove last segment
remove N bytes from last segment
brk(addr) ( where addr == byte N of segment S )
if addr in current last segment, then set
segment size to N
if addr in next segment, then same as sbrk(N)
if addr in an allocated part of a previous segment
then throw away everything above addr
else error
--
member, all HASA divisions POELOD ECBOMB
--------------
^-- Secret Satanic Message
Tim Smith USENET: sdcrdcf!ism780c!tim Compuserve: 72257,3706
Delphi or GEnie: mnementh
Technical Details
Message-ID:
<4104@ism780c.UUCP>Path:
arc1-ca.pugleaf.net!utzoo!watmath!clyde!rutgers!sri-spam!sri-unix!hplabs!sdcrdcf!ism780c!timReferences:
<646@chinet.UUCP>Show Full Headers
Complete Article Headers
Relay-Version: version B 2.10 5/3/83; site utzoo.UUCP Path: arc1-ca.pugleaf.net!utzoo!watmath!clyde!rutgers!sri-spam!sri-unix!hplabs!sdcrdcf!ism780c!tim From: tim@ism780c.UUCP (Tim Smith) Newsgroups: net.lang.c,net.unix Subject: Re: Microport and SCO Xenix Memory Managment Problems Message-ID: <4104@ism780c.UUCP> Date: Fri, 24-Oct-86 23:41:05 EST Article-I.D.: ism780c.4104 Posted: Fri Oct 24 23:41:05 1986 Date-Received: Sun, 26-Oct-86 03:37:42 EST References: <646@chinet.UUCP> Reply-To: tim@ism780c.UUCP (Tim Smith) Organization: Interactive Systems Corp., Santa Monica, CA Lines: 49 Keywords: sbrk, brk, Microport, SCO Xenix