Re: User mode APCs, paged or non-paged heap?

Tech Tip: Click here to run a free scan for Windows Errors and optimize PC performance



The word I think has a specific meaning. It means the normal user mode
application chunk of memory managed by the alloc, malloc, calloc, etc. used
by 'C' programs. It may also include C++, but I never looked. Drivers
don't have heaps. There are two pools in the kernel that are fixed, mostly,
in size based upon parameters and the environment when booting. One is the
non-paged pool and the other the paged pool. You can allocate from either
and free. The reason you don't have to specify the pool type in the free
call is that the OS knows from the address which pool it came from. Even
with the pools and the other issues with page sizes most allocations work
best if you just get what you need. In some ways it is more for debugging
but not so much for efficiency that you do it that way. Many drivers that
have very dynamic memory requirements during a single run, will allocate
some multiple of page size and do their own memory allocation within that
block. The OS offers support for some of that too, but it is not compiler
based as it is in user land.

Even in applications you can go outside the programming language to allocate
memory directly from the OS instead of from the heap manager code in the
RTL. I think extremely large allocations are done using this method.

In summary, I think 'heap' is not to be used in kernel mode. Since Windows
NT came from another OS the terminology was already invented. The use of
'heap' may have been an artifact of DOS or Windows 1, 2, 3, 9x, etc.

"Hugo gleaves@xxxxxxxxxxx>" <hugh<underbar> wrote in message
news:008DDABA-B0EA-492D-8111-25DBAF863EDF@xxxxxxxxxxxxxxxx
Hello Don

Thanks for clarifying that. What confused me is the way that Microsoft use
the term heap and pool for the same thing, take a look inside the last
'Windows Internals' book, those authors talk about paged and non-paged
kernel
heaps and then later start using the term pool and non-paged pool without
batting an eye lash.

It would help if MS were consistent here I think, I mean why do they use
the
term 'pool tags' when they could just say 'heap tags'?

I don't know whether "pool" has a specific defined meaning or not, I
recall
working a lot on Stratus hardware many years ago, their VOS operating
system
(a derivative - dare I say clone - of Multics) also used the term 'pool'
but
also used the term 'heap'.

We have a library that we developed that allows a coder to 'create' a
'pool'
and specify a size. Once that is done you can alloc/free blocks of a given
size much more rapidly and with less memory, so long as they are the same
size, you can create many such pools and they grow/shrink dynamically,
just
calling allocate_pool (size) is enough, the logic sees if a pool
supporting
that size has been created and uses it (else returns an error).

This is very fast in systems that have a need to (potentially) allocate
large numbers (millions+) of identical structures, in a concurrent system
only the pool itself need be locked and each allocation has no header etc
so
storage efficiency is very good.

Do you know off-hand if those APC allocations are from paged or non-paged
heap incidentally?

Thx
H




"Don Burn" wrote:

No, in the Windows kernel the term pool means the heap or pool of memory
for
allocation. The memory_pool term is something that came out of other
OS'es
but historically it has never meant fixed size blocks (at least it did
not
on any of the OS'es I worked with in the 70's and early 80's except some
Unix stuff). So think of pool as a heap, and stay away from Wikipedia it
is
pretty crappy and inaccurate for most things related to Windows.


--
Don Burn (MVP, Windows DDK)
Windows Filesystem and Driver Consulting
Website: http://www.windrvr.com
Blog: http://msmvps.com/blogs/WinDrvr
Remove StopSpam to reply



"Hugo gleaves@xxxxxxxxxxx>" <hugh<underbar> wrote in message
news:3BB50D2A-19D1-4188-931A-1EC5FBE7F0D2@xxxxxxxxxxxxxxxx
Does anyone know if queued user-mode APCs are allocated from paged or
non-paged heap?

It seems there are two tags used for this, Psap and PsAp, not sure what
the
specific roles of each is though.

Also, can someone clarify the term "pool" with respect to Windows? I
know
there is the paged and non-paged heap that kernel mode code can
allocate/free
from but I also see the term paged and non-paged pool being used.

My own understanding is that in general a pool is a means of rapdily
allocating/freeing blocks that are always the same size and is more
efficient
than using just a standdard heap allocate/free operation.

See: http://en.wikipedia.org/wiki/Memory_pool

We have code that does this for us, we allocate from a pool (of some
defined
size) which consists of a header and a variable length list of fixed
size
blocks that can hold 1024 'items' we allocate/free the large blocks
from/to
the heap, but then allocate the smaller chunks from within these blocks
(i.e.
the blocks are percieved as 'arrays').

Does Windows do something similar internally?

Thx








.



Relevant Pages

  • Re: Struct inside class
    ... The compiler figures computes the ... including anything derived from "Object": Heap pointer ... memory leaks and why the .NET good garbage collector is required. ... If GC_ALLOCATE can't allocate the requested ...
    (microsoft.public.dotnet.framework)
  • Re: run-time vs compile-time
    ... > offset related to some location (like stack base) somewhere. ... > offset from heap to pi. ... When you allocate an int on the heap, it is allocated at address 1. ... application has a given amount of memory it can use as it wishes. ...
    (alt.comp.lang.learn.c-cpp)
  • Re: run-time vs compile-time
    ... > offset related to some location (like stack base) somewhere. ... > offset from heap to pi. ... When you allocate an int on the heap, it is allocated at address 1. ... application has a given amount of memory it can use as it wishes. ...
    (comp.lang.cpp)
  • Re: Huge pages and small pages. . .
    ... >> what looks like contiguous memory and away you go. ... you need to have them cached in the TLB; if the TLB runs out of ... > low end of the heap, until someone figures out a way to tell the system ... When you allocate memory, the kernel just marks a promised ...
    (Linux-Kernel)
  • Re: Help!!! Memory allocation!!!
    ... I'm trying to map the continuous memory to user space address. ... dont know if the MmAllocateContiguousMemory didnt allocate the continuous ... memory from non-paged pool but from paged pool or some other places, ... Lock it first whatever it is allocated from nonpaged pool or not ...
    (microsoft.public.development.device.drivers)