Comments on: Ready, Set, Allocate! (Part 3) Hey Paul, I'm glad to hear that it works, and thanks for writing such a good and interesting serie here on alt-dev! I'll hook you up on linkedin. Cheers, Simon Hey Paul,

I’m glad to hear that it works, and thanks for writing such a good and interesting serie here on alt-dev! I’ll hook you up on linkedin.

Cheers,
Simon

]]>
By: Paul Laska/2011/05/15/ready-set-allocate-part-3/#comment-5553 Paul Laska Sun, 12 Jun 2011 06:09:22 +0000 Hey Paul, Your logic seems to work but I am wondering if it can be made even simpler? <code> if pagesrequested >= pagesperunit - preoffset then remainingpages = pagesrequested - (pagesperunit - preoffset) else remainingpages = 0 </code> or am I missing something? Cheers, Simon Hey Paul,

Your logic seems to work but I am wondering if it can be made even simpler? if pagesrequested >= pagesperunit - preoffset then remainingpages = pagesrequested - (pagesperunit - preoffset) else remainingpages = 0 or am I missing something?

Cheers,
Simon

]]>
By: Paul Laska/2011/05/15/ready-set-allocate-part-3/#comment-5461 Paul Laska Fri, 10 Jun 2011 08:44:38 +0000 Hey Paul! Thanks for the correction! Looking at the code, if you have 32 pages / unit and you do a request that needs 21 pages. Wouldn't that mean that uNumPagesNotNeeded would be 11? If uNumPagesNotNeeded is 11 and uPreOffset would be 7 (let's pretend that the first pages are filled already). Wouldn't that mean that the comparison would be: <code> 21 >= ((uint)32 - ((uint)7 - (uint)11). </code> Now that seem like it would cause uint-underflow, which on most platforms probably would result in a "correct" solution - but I'm wondering if it's intentioned or accidential? The issue that I was really looking for when going through the code was the case of a 21-page request on a 14-pages filled 32 pages-per-unit-case. The result becomes: <code> 21 >= (32-(14-11)) </code> Which is false, which means that uNumRemainingPagesNeeded is 0. Isn't that false? There's only 18 pages left, which means that I have 3 pages that won't get allocated from the page-table. Cheers, Simon Hey Paul!

Thanks for the correction!

Looking at the code, if you have 32 pages / unit and you do a request that needs 21 pages. Wouldn’t that mean that uNumPagesNotNeeded would be 11? If uNumPagesNotNeeded is 11 and uPreOffset would be 7 (let’s pretend that the first pages are filled already). Wouldn’t that mean that the comparison would be:

21 >= ((uint)32 - ((uint)7 - (uint)11).

Now that seem like it would cause uint-underflow, which on most platforms probably would result in a “correct” solution – but I’m wondering if it’s intentioned or accidential?

The issue that I was really looking for when going through the code was the case of a 21-page request on a 14-pages filled 32 pages-per-unit-case. The result becomes:

21 >= (32-(14-11))

Which is false, which means that uNumRemainingPagesNeeded is 0. Isn’t that false? There’s only 18 pages left, which means that I have 3 pages that won’t get allocated from the page-table.

Cheers,
Simon

]]>
By: Paul Laska/2011/05/15/ready-set-allocate-part-3/#comment-5453 Paul Laska Fri, 10 Jun 2011 07:40:55 +0000 Hey Paul, I've been looking into your implementation a bit and there's a few things that I can't really get around to understand. When calculating remaining pages needed, you check if the required pages are larger than (kMemNumPagesPerUnit - (uPreOffset - uNumPagesNotNeeded)). Isn't it possible that preoffset can be smaller than numpagesnotneeded? (specifically since uPreOffset easily can become 0). Hey Paul,

I’ve been looking into your implementation a bit and there’s a few things that I can’t really get around to understand. When calculating remaining pages needed, you check if the required pages are larger than (kMemNumPagesPerUnit – (uPreOffset – uNumPagesNotNeeded)). Isn’t it possible that preoffset can be smaller than numpagesnotneeded? (specifically since uPreOffset easily can become 0).

]]>
By: Paul Laska/2011/05/15/ready-set-allocate-part-3/#comment-4161 Paul Laska Mon, 16 May 2011 00:55:08 +0000 Hello Paul, I just started reading this series of articles. Very interesting! At the beginning of this series, you said: "A memory heap system that replaces the built-in allocation system can help to overcome many slow down situations." Can you explain why this is the case? I expect that you get the advantage by making assumptions about your memory usage that the built-in allocator cannot. However, I haven't been able to figure out what those assumptions might be, as your allocator seems to be fairly general-purpose. Thanks! Hello Paul, I just started reading this series of articles. Very interesting! At the beginning of this series, you said: “A memory heap system that replaces the built-in allocation system can help to overcome many slow down situations.” Can you explain why this is the case?

I expect that you get the advantage by making assumptions about your memory usage that the built-in allocator cannot. However, I haven’t been able to figure out what those assumptions might be, as your allocator seems to be fairly general-purpose.

Thanks!

]]>