
CE.NET: Allocation of linear address space
Windows CE sets up the processor to use virtual addresses for all its work.
It isn't your concern particularly whether the physical memory addresses are
actually contiguous; all that matters is that the OS has mapped those
addresses to contiguous virtual addresses. Which it does, for
CreateFileMapping.
The only situation in which you need contiguous PHYSICAL memory is if you
intend to do DMA, where another hardware component is going to take charge
of the bus and do its own transfer. In that situation, it needs to know the
physical memory addresses.
The difference between AllocPhysMem and VirtualAlloc is then that
AllocPhysMem allocates physical memory as addressed at hardware level, but
VirtualAlloc allocates page-size blocks of virtual memory, which could be
physically located anywhere, and not necessarily contiguously, and sets up
the page address translation tables correctly for this purpose.
Note also that if you're performing lots of small allocations, you should
use the HeapAlloc() functions, the LocalAlloc() functions, or the C/C++
runtime functions such as malloc or 'operator new'. VirtualAlloc is useful
for creating a bigger, page-size scratchpad.
Remember that Windows CE doesn't do any paging. You'll only be able to
allocate that 32Mb-48Mb block if the device has at least 64Mb of memory AND
if the user hasn't already used too much object store.
HTH,
--
Mike Dimmick
Quote:
> CreateFileMapping, as well as VirtualAlloc might be one possibility to do
> it.
> But: Is it really linear address space ??
> I found the new CE.NET memory management function AllocPhysMem in the
> meanwhile. The documentation mentions that this function allocates
> physically contiguously memory. So, this seems to be what I was looking
for.
> Just some more questions concerning this new CE.net function:
> What is the difference between AllocPhysMem and VirtualAlloc ?
> Why was it necessary to "invent" this new function ?
> When to use what function ?
> Thanks
> Juergen
> > Look into the CreateFileMapping function on MSDN
(http://msdn.microsoft.com/library/default.asp?url=/library/en-us/wceo...
Quote:
> > tm/cerefCreateFileMapping.asp). This might work for you.
> > Jeff
> > --
> > This posting is provided "AS IS" with no warranties, and confers no
> rights.
> > You assume all risk for your use. ? 2002 Microsoft Corporation. All
rights
> > reserved.
> > > Hi
> > > How can a linear address space of at least 32MB (up to 48MB) be
> allocated
> > > using Win CE.NET ?
> > > Thanks
> > > Juergen