[comp.sys.amiga.tech] Memory Types???

haitex@pnet01.cts.com (Wade Bickel) (04/18/88)

    Can someone please tell me the proper memory nomenclature?  What I want to
define are three different catagories of memory request:

                CHIP   :   must be chip memory.

                FAST   :   must be fast memory.

                FSCH   :   fast if possible, if not the chip if possible.

    Right now, these are always private to the requesting task.  I'd like to
set up the memory allocation system so that it returns memory as fast as
possible and has reasonalbe garbage collection and defragmentation capability.

    Also, I am considering forcing longword alignment.  Since I am already 
using 8 bytes for link fields and these really should be on lw boundries it
seems worthwhile to me.

                                                        Thanks,


                                                              Wade.

UUCP: {cbosgd, hplabs!hp-sdd, sdcsvax, nosc}!crash!pnet01!haitex
ARPA: crash!pnet01!haitex@nosc.mil
INET: haitex@pnet01.CTS.COM

dillon@CORY.BERKELEY.EDU (Matt Dillon) (04/19/88)

:    Can someone please tell me the proper memory nomenclature?  What I want to
:define are three different catagories of memory request:
:
:                CHIP   :   must be chip memory.

	ptr = AllocMem(bytes, MEMF_PUBLIC|MEMF_CHIP);
:
:                FAST   :   must be fast memory.
:
	ptr = AllocMem(bytes, MEMF_PUBLIC|MEMF_FAST);

:                FSCH   :   fast if possible, if not the chip if possible.

	ptr = AllocMem(bytes, MEMF_PUBLIC);

	I.E. EXEC searches for space in fast memory before chip memory.

:
:    Right now, these are always private to the requesting task.  I'd like to
:set up the memory allocation system so that it returns memory as fast as
:possible and has reasonalbe garbage collection and defragmentation capability.

	Unless you intend to go for double-indirect pointers, the EXEC
memory system defragments as much as is possible without moving already-
alocated chunks around.

:
:    Also, I am considering forcing longword alignment.  Since I am already 
:using 8 bytes for link fields and these really should be on lw boundries it
:seems worthwhile to me.
:
:                                                        Thanks,
:
:
:                                                              Wade.

	The EXEC memory system always returns memory on 8-byte boundries
(double longword boundries).  As far as I can tell, unless you want to
use double indirect pointers, the EXEC memory system is the way to go.

			-Matt

cmcmanis%pepper@Sun.COM (Chuck McManis) (04/20/88)

In article <2840@crash.cts.com> haitex@pnet01.cts.com (Wade Bickel) writes:
>                FSCH   :   fast if possible, if not the chip if possible.

This should really be the default behaviour (and it is). Passing 0 to 
AllocMem says "Get me the fastest memory that has a chunk in it that is
<size> bytes long."


--Chuck McManis
uucp: {anywhere}!sun!cmcmanis   BIX: cmcmanis  ARPAnet: cmcmanis@sun.com
These opinions are my own and no one elses, but you knew that didn't you.

cmcmanis%pepper@Sun.COM (Chuck McManis) (04/20/88)

In article <8804182055.AA15423@cory.Berkeley.EDU> (Matt Dillon) writes:
>:                FSCH   :   fast if possible, if not the chip if possible.
>
>	ptr = AllocMem(bytes, MEMF_PUBLIC);

Correct me if I am wrong, but the word I heard was that MEMF_PUBLIC was
only for memory that you would want to share with other tasks. Not for
private memory that you wanted for yourself. 

--Chuck McManis
uucp: {anywhere}!sun!cmcmanis   BIX: cmcmanis  ARPAnet: cmcmanis@sun.com
These opinions are my own and no one elses, but you knew that didn't you.

cjp@antique.UUCP (Charles Poirier) (04/20/88)

In article <8804182055.AA15423@cory.Berkeley.EDU> dillon@CORY.BERKELEY.EDU.UUCP writes:
|:    Can someone please tell me the proper memory nomenclature?  What I want to
|:define are three different catagories of memory request:
|:
|:                CHIP   :   must be chip memory.
|
|	ptr = AllocMem(bytes, MEMF_PUBLIC|MEMF_CHIP);
|:
|:                FAST   :   must be fast memory.
|:
|	ptr = AllocMem(bytes, MEMF_PUBLIC|MEMF_FAST);

Huh?  What I understood was that this construct gives the same result
as the request below without MEMF_FAST, giving CHIP when insufficient
FAST is available.  One solution (suboptimal, but hey) would be to
request MEMF_FAST, then check the returned pointer with TypeOfMem()
(sp?  was just recently the subject of a posting), and if it's CHIP,
FreeMem it and fail.  You'd want to think carefully about using this,
as many Amigas have only CHIP memory.

By the way, did Matt really mean to imply that *every* AllocMem should
ask for MEMF_PUBLIC?

|:                FSCH   :   fast if possible, if not the chip if possible.
|
|	ptr = AllocMem(bytes, MEMF_PUBLIC);
|
|	I.E. EXEC searches for space in fast memory before chip memory.

-- 
	Charles Poirier   (decvax,ihnp4,attmail)!vax135!cjp

   "Docking complete...       Docking complete...       Docking complete..."

dillon@CORY.BERKELEY.EDU (Matt Dillon) (04/20/88)

:>
:>	ptr = AllocMem(bytes, MEMF_PUBLIC);
:
:Correct me if I am wrong, but the word I heard was that MEMF_PUBLIC was
:only for memory that you would want to share with other tasks. Not for
:private memory that you wanted for yourself. 
:
:--Chuck McManis

	Exactly right, but then there is the matter of what memory
should be public and what should not.  Since the flag was never 
seriously described, NOBODY uses it correctly, and thus the flag is useless.

	So it really doesn't matter.  But I always use MEMF_PUBLIC because
it covers all possible cases (in the vapor meaning of the term).  If C-A
ever gets serious about it, they will have to add a new flag bit.

				-Matt

dpvc@ur-tut (Davide P. Cervone) (04/20/88)

In article <2187@antique.UUCP> cjp@vax135.UUCP (Charles Poirier) writes:
>In article <8804182055.AA15423@cory.Berkeley.EDU> dillon@CORY.BERKELEY.EDU.UUCP writes:
>|	ptr = AllocMem(bytes, MEMF_PUBLIC|MEMF_FAST);
>
>Huh?  What I understood was that this construct gives the same result
>as the request below without MEMF_FAST, giving CHIP when insufficient
>FAST is available.

No, Matt was right, the above AllocMem FAILS if there is no FAST memory
available.  It does NOT return CHIP memory.  I've tried it, it fails.

	ptr = AllocMem(bytes,0L);

gets you FAST memory if it exists, and CHIP if not.  Matt's third example 
does this as well, but its memory is PUBLIC, which seems to have confused
some people.  You don't need thte MEMF_PUBLIC bit, but it doesn't hurt,
either.

Davide P. Cervone
dpvc@tut.cc.rochester.edu
dpvc@ur-tut.UUCP
DPVC@UORDBV.BITNET