Article View: comp.os.msdos.programmer
Article #2828Re: SUMMARY: MSDOS memory FREE functionc
From: Ralf Brown
Date: Sun, 28 Oct 1990 02:34
Date: Sun, 28 Oct 1990 02:34
32 lines
2425 bytes
2425 bytes
In article <1990Oct28.001029.19179@watdragon.waterloo.edu> dvadura@watdragon.waterloo.edu (Dennis Vadura) writes:
}Summary of MSDOS FREE and memory coalescing. A while back I posted
}a request if anyone knows how to get DOS FREE (int 21, ah=0x49) to coalesce
}adjacent blocks. I received several responses and based on those come to these
}conclusions. DOS FREE on its own does NOT coalesce adjacent free memory blocks.
}(in my opinion this is stupid). DOS ALLOC (int 21, ah=0x48) of a block
}whose size is 0xffff seems to do the trick. FREEING that resulting block has
}the effect of coalescing all previously allocated but now free adjacent blocks.
I've since looked at the actual DOS memory management code, and can state that
generic MSDOS 3.30 works as follows:
no coalescing on FREE
all possible blocks coalesced on *any* ALLOC
free blocks immediately following a block being RESIZEd are coalesced
Also, the coalescing on ALLOC is done by calling a coalesce routine on each
free block, to coalesce any immediately following free blocks (same code that
is called by the RESIZE coalescing). Since the DOS memory chain is not
doubly-linked, omitting the coalescing on FREE is an overall performance
win, since it would be necessary to walk the memory chain to find the
preceding memory block (which might already be free and need to be coalesced).
ALLOC walks the entire memory chain anyway....
Note: if the alloc of FFFFh paragraphs is ever successful, your memory chain
must be corrupted, since that is 1M-16 bytes.... DOS doesn't allocate any
memory if there is no sufficiently large block available. Thus there is no
need for the call to FREE after the alloc of FFFFh paragraphs.
--
{backbone}!cs.cmu.edu!ralf ARPA: RALF@CS.CMU.EDU FIDO: Ralf Brown 1:129/3.1
BITnet: RALF%CS.CMU.EDU@CMUCCVMA AT&Tnet: (412)268-3053 (school) FAX: ask
DISCLAIMER? Did | Everything is funny as long as it is happening to
I claim something?| someone else. --Will Rogers
Technical Details
Message-ID:
<10886@pt.cs.cmu.edu>Path:
arc1-ca.pugleaf.net!utzoo!attcan!uunet!cs.utexas.edu!rutgers!rochester!pt.cs.cmu.edu!b.gp.cs.cmu.edu!ralfReferences:
<1990Oct28.001029.19179@watdragon.waterloo.edu>Show Full Headers
Complete Article Headers
Path: arc1-ca.pugleaf.net!utzoo!attcan!uunet!cs.utexas.edu!rutgers!rochester!pt.cs.cmu.edu!b.gp.cs.cmu.edu!ralf From: ralf@b.gp.cs.cmu.edu (Ralf Brown) Newsgroups: comp.os.msdos.programmer Subject: Re: SUMMARY: MSDOS memory FREE functionc Message-ID: <10886@pt.cs.cmu.edu> Date: 28 Oct 90 02:34:26 GMT References: <1990Oct28.001029.19179@watdragon.waterloo.edu> Organization: Carnegie-Mellon University, CS/RI Lines: 32