Relay-Version: version B 2.10 5/3/83; site utzoo.UUCP Path: utzoo!mnetor!uunet!husc6!mit-eddie!uw-beaver!cornell!rochester!PT!andrew.cmu.edu!jdr+ From: jdr+@andrew.cmu.edu (Jeff Rosenfeld) Newsgroups: comp.os.minix Subject: Re: what does brk do on segmented architectures? Message-ID: Date: Tue, 6-Oct-87 14:40:23 EDT Article-I.D.: andrew.AVOHYLy00Xo-zIc0ZT Posted: Tue Oct 6 14:40:23 1987 Date-Received: Fri, 9-Oct-87 07:12:43 EDT Organization: Carnegie Mellon University Lines: 26 In-Reply-To: <214@drilex.UUCP> > For non-linear address spaces, such as Zilogs or Intels, generally there is > no simple 'sbrk' or 'brk', except in the degenerate memory models. > Generally > there is one 'brk' per segment, and a call which sets it. On the 80286 under Xenix 286, there are reasonable versions of brk and sbrk. Using a small data memory model (one 64K segment), they work just like they should. Using a large data memory model (multiple 64K segments), the brk limit is set or incremented as though the far pointer were a pointer in a linear address space except that only valid segment selectors are allowed and the selectors are in numerical order. In this way, you can sbrk() more than 64K in which case more than one segment will be allocated to you and the selectors for those segments will be incremented by 8 (a magic number related to the meanings of bits in a selector) for each segment beyond the one referenced by the return value from sbrk(). Since a segment must be full (its limit must be 64K) before another is allocated, there need be only one brk for the whole program. This does not imply that contiguous physical memory is allocated; only that the segments allocated do not overlap in physmem. It is also possible to allocate segments about which brk doesn't know, but using that facility invalidates brk's operation. The only serious problem (from a user's perspective) with implementing brk() and sbrk() on a segmented architecture is that your pointers are not perfectly linear and so subtraction of pointers whose selectors are different might be an undefined operation.