Re: Does Bill Gates know about the DDK regarding C++?



The key to avoiding the fragmentation is to size the private heaps properly.
If you do that correctly, you should never have to start invoking
ExAllocatePool with tiny request sizes. The private heap implementation does
one large allocation at driver load time and then suballocates out of that
memory to satisfy the STL requirements.

I would not advocate doing a large number of small allocations with
ExAllocatePool.

Mike

"Doron Holan [MS]" wrote:

> not to mention that it also creats a bunch of tiny allocations, fragmenting
> precious system VA.
>
> d
>
> --
> Please do not send e-mail directly to this alias. this alias is for
> newsgroup purposes only.
> This posting is provided "AS IS" with no warranties, and confers no rights.
>
>
> "Mike Yoke" <MikeYoke@xxxxxxxxxxxxxxxxxxxxxxxxx> wrote in message
> news:1CF7B97C-ADE4-4A09-B9A1-372903C3E615@xxxxxxxxxxxxxxxx
> > Yeah, the allocation is a pain but the containers and algortithms are
> > still
> > useful.
> >
> > Mike
> >
> >
> > "Doron Holan [MS]" wrote:
> >
> >> so wrap all usage of the STL object in SEH blocks and then only call it
> >> at
> >> passive_level? doesn't sound very useful to me.
> >>
> >> d
> >>
> >> --
> >> Please do not send e-mail directly to this alias. this alias is for
> >> newsgroup purposes only.
> >> This posting is provided "AS IS" with no warranties, and confers no
> >> rights.
> >>
> >>
> >> "Mike Yoke" <MikeYoke@xxxxxxxxxxxxxxxxxxxxxxxxx> wrote in message
> >> news:D394F7B0-1089-4C4E-92BC-8D11BA9498AA@xxxxxxxxxxxxxxxx
> >> > ExRaiseStatus(STATUS_INSUFFICIENT_RESOURCES);
> >> >
> >> > "Doron Holan [MS]" wrote:
> >> >
> >> >> which can fail as well. what then?
> >> >>
> >> >> d
> >> >>
> >> >> --
> >> >> Please do not send e-mail directly to this alias. this alias is for
> >> >> newsgroup purposes only.
> >> >> This posting is provided "AS IS" with no warranties, and confers no
> >> >> rights.
> >> >>
> >> >>
> >> >> "Mike Yoke" <MikeYoke@xxxxxxxxxxxxxxxxxxxxxxxxx> wrote in message
> >> >> news:17E51389-6ABD-4274-8DE6-FBFF56D234A6@xxxxxxxxxxxxxxxx
> >> >> > The allocator uses a low-memory handler that gets invoked in the
> >> >> > event
> >> >> > that
> >> >> > allocations from the private heap fail. The low-memory handler then
> >> >> > acquires
> >> >> > more memory from the system via ExAllocatePool.
> >> >> >
> >> >> > Mike
> >> >> >
> >> >> > "Doron Holan [MS]" wrote:
> >> >> >
> >> >> >> IIRC, the STL code didn't check the return results from an
> >> >> >> allocation.
> >> >> >> so
> >> >> >> you eliminated exceptions, but you didn't add any error handling.
> >> >> >> since
> >> >> >> allocs can fail, did you modify each STL container as well?
> >> >> >>
> >> >> >> --
> >> >> >> Please do not send e-mail directly to this alias. this alias is for
> >> >> >> newsgroup purposes only.
> >> >> >> This posting is provided "AS IS" with no warranties, and confers no
> >> >> >> rights.
> >> >> >>
> >> >> >>
> >> >> >> "Mike Yoke" <MikeYoke@xxxxxxxxxxxxxxxxxxxxxxxxx> wrote in message
> >> >> >> news:5BB17C3E-FAFA-4D38-A1D2-EAECFDE57FAB@xxxxxxxxxxxxxxxx
> >> >> >> > In my original post I said I used STL with a custom allocator
> >> >> >> > written
> >> >> >> > explicitly for kernel mode use. It basically creates two private
> >> >> >> > heaps
> >> >> >> > at
> >> >> >> > driver load time, one paged and one non-paged, and manages all
> >> >> >> > the
> >> >> >> > small
> >> >> >> > allocations that STL tends to make out of this private heap. It
> >> >> >> > also
> >> >> >> > does
> >> >> >> > not
> >> >> >> > throw exceptions. Also, I studied the implementations of the
> >> >> >> > containers
> >> >> >> > and
> >> >> >> > algorithms I chose to use to make sure I understood the code that
> >> >> >> > was
> >> >> >> > being
> >> >> >> > generated.
> >> >> >> >
> >> >> >> > I don't advocate blind and careless use of C++ and STL in kernel
> >> >> >> > mode,
> >> >> >> > but
> >> >> >> > it can be used successfully.
> >> >> >> >
> >> >> >> > Mike
> >> >> >> >
> >> >> >> > "Doron Holan [MS]" wrote:
> >> >> >> >
> >> >> >> >> STL has no place in the kernel. it assumes allocations always
> >> >> >> >> succeed
> >> >> >> >> and
> >> >> >> >> upon failure, throw c++ exceptions. that just doesn't work in
> >> >> >> >> the
> >> >> >> >> kernel
> >> >> >> >> at
> >> >> >> >> all.
> >> >> >> >>
> >> >> >> >> d
> >> >> >> >>
> >> >> >> >> --
> >> >> >> >> Please do not send e-mail directly to this alias. this alias is
> >> >> >> >> for
> >> >> >> >> newsgroup purposes only.
> >> >> >> >> This posting is provided "AS IS" with no warranties, and confers
> >> >> >> >> no
> >> >> >> >> rights.
> >> >> >> >>
> >> >> >> >>
> >> >> >> >> "Don Burn" <burn@xxxxxxxxxxxxxxxx> wrote in message
> >> >> >> >> news:fdBpe.12948$mZ2.1718@xxxxxxxxxxx
> >> >> >> >> > Actually, I was trying to make it not a flame war. Note, I
> >> >> >> >> > cautioned
> >> >> >> >> > against C++ but fully acknowledged people do it. I will
> >> >> >> >> > emphatically
> >> >> >> >> > argue against STL in the kernel. You can use C++, but you
> >> >> >> >> > need
> >> >> >> >> > to
> >> >> >> >> > understand impacts for you and for people who pick up the code
> >> >> >> >> > in
> >> >> >> >> > the
> >> >> >> >> > future.
> >> >> >> >> >
> >> >> >> >> > I did not mention that WDF is written in C++ because it was
> >> >> >> >> > specifically
> >> >> >> >> > relavent. As I said a good expert can do it, and this is
> >> >> >> >> > their
> >> >> >> >> > choice,
> >> >> >> >> > particualarily if you have a team in place. Now I could have
> >> >> >> >> > mentioned,
> >> >> >> >> > that because of earlier statements about WDF being written in
> >> >> >> >> > C++
> >> >> >> >> > I
> >> >> >> >> > know
> >> >> >> >> > of a consultant who has switched to the language without
> >> >> >> >> > understanding
> >> >> >> >> > the
> >> >> >> >> > implications. His kernel code which was weak but ok, has now
> >> >> >> >> > gone
> >> >> >> >> > to
> >> >> >> >> > dog***.
> >> >> >> >> >
> >> >> >> >> >
> >> >> >> >> > --
> >> >> >> >> > Don Burn (MVP, Windows DDK)
> >> >> >> >> > Windows 2k/XP/2k3 Filesystem and Driver Consulting
> >> >> >> >> > Remove StopSpam from the email to reply
> >> >> >> >> >
> >> >> >> >> >
> >> >> >> >> >
> >> >> >> >> > "Robert Marquardt" <marquardt@xxxxxxxxxxxxx> wrote in message
> >> >> >> >> > news:OMjf$2%23aFHA.3100@xxxxxxxxxxxxxxxxxxxxxxx
> >> >> >> >> >> Mark Roddy wrote:
> >> >> >> >> >>
> >> >> >> >> >>> Don forgot to mention that WDF is written entirely in C++,
> >> >> >> >> >>> except
> >> >> >> >> >>> of
> >> >> >> >> >>> course for the exposed C api for us mere mortals. I rest my
> >> >> >> >> >>> case.
> >> >> >> >> >>
> >> >> >> >> >> You are right. This is again a flame war.
> >> >> >> >> >> The original question was about APIs.
> >> >> >> >> >> APIs hould stay C APIs because C++ has no language agnostic
> >> >> >> >> >> interface.
> >> >> >> >> >>
> >> >> >> >> >> I personally dislike C++ for the very reason others praise
> >> >> >> >> >> it.
> >> >> >> >> >> The reason is "C++ is the richest language of all". This is
> >> >> >> >> >> precisely
> >> >> >> >> >> the
> >> >> >> >> >> problem. An average programmer does not master C++ fully
> >> >> >> >> >> resulting
> >> >> >> >> >> in
> >> >> >> >> >> bad
> >> >> >> >> >> programs.
> >> >> >> >> >> Java, Delphi and C# are popular becasue they all have less
> >> >> >> >> >> language
> >> >> >> >> >> features than C++ allowing average programmers to master
> >> >> >> >> >> them.
> >> >> >> >> >
> >> >> >> >> >
> >> >> >> >>
> >> >> >> >>
> >> >> >> >>
> >> >> >>
> >> >> >>
> >> >> >>
> >> >>
> >> >>
> >> >>
> >>
> >>
> >>
>
>
>
.


Loading