🚀 go-pugleaf

RetroBBS NetNews Server

Inspired by RockSolid Light RIP Retro Guy

Article View: comp.os.msdos.programmer
Article #4642

Re: farmolloc and malloc

#4642
From: Rahul Dhesi
Date: Sat, 09 Feb 1991 02:31
30 lines
2039 bytes
In <30456@shamash.cdc.com> jeff@u02.svl.cdc.com (Jeff Needham) writes:

>No matter what I try, or how small my program is, I find that "malloc" and
>"farmalloc" allocate space in the same segment, which starts out at about
>62000 bytes long. At the very least, I wish they could use two different
>segments of that size.

Typically when you call malloc or farmalloc, they will allocate memory
sequentially, allocating as many bytes as you ask for, and always
allocating the next block from roughly where the previous bllocation
left off.

In Intel CPU-based machines, the concept of "same segment" exists only
before the program is linked.  Once it is linked and loaded, memory is
in a linear address space, and only its *addressing* is segmented.
(The CPU knows about segments but the memory hardware does not.)  The
real memory address is always linear, but it can be expressed in
different ways using different values for segment and offset.

So, if you want to treat different blocks of memory as being in
different segments, you can do so, but it has nothing to do with how it
is allocated.  Just assign any combination of segment and offset to
your registers.  Any two memory addresses that are within 64K of each
other can be assumed to be either in the same segment or in different
segments, as you prefer.  Memory addresses that are further than 64K
apart as in different segments because you must reload your segment
register between references.
--
Rahul Dhesi <dhesi%cirrusl@oliveb.ATC.olivetti.com>
UUCP:  oliveb!cirrusl!dhesi
Technical Details
Message-ID: <2936@cirrusl.UUCP>
Path: arc1-ca.pugleaf.net!utzoo!mnetor!tmsoft!torsqnt!lethe!yunexus!ists!helios.physics.utoronto.ca!news-server.csri.toronto.edu!cs.utexas.edu!uunet!olivea!tymix!cirrusl!sunstorm!dhesi
References: <30456@shamash.cdc.com>

Show Full Headers
Complete Article Headers
Path: arc1-ca.pugleaf.net!utzoo!mnetor!tmsoft!torsqnt!lethe!yunexus!ists!helios.physics.utoronto.ca!news-server.csri.toronto.edu!cs.utexas.edu!uunet!olivea!tymix!cirrusl!sunstorm!dhesi
From: dhesi%cirrusl@oliveb.ATC.olivetti.com (Rahul Dhesi)
Newsgroups: comp.os.msdos.programmer
Subject: Re: farmolloc and malloc
Message-ID: <2936@cirrusl.UUCP>
Date: 9 Feb 91 02:31:29 GMT
References: <30456@shamash.cdc.com>
Sender: news@cirrusl.UUCP
Organization: Cirrus Logic Inc.
Lines: 30