Page 1 of 1

Questions about Pancakes' heap implementation with bitmaps

Posted: Fri Feb 05, 2021 9:56 am
by j4cobgarby
I've been looking at this page: https://wiki.osdev.org/User:Pancakes/Bi ... ementation. I understand the basic theory of this, I think: the heap is a linked list of memory blocks. Each block which is part of the heap has a header in the first few bytes of it, saying where the next block is, as well as some metadata. Directly following the header, there is a bitmap, where each bit represents the availability of a corresponding region of memory within this block. The size of that region of memory is configurable per block, it seems.

There are some things I don't understand about this implementation though, namely:

- Why, when initialising a new block, are the bytes in the bitmap set to 0x05?
- Other than that, am I right about my understanding of this?

Re: Questions about Pancakes' heap implementation with bitma

Posted: Fri Feb 05, 2021 11:23 am
by justinian
j4cobgarby wrote: - Why, when initialising a new block, are the bytes in the bitmap set to 0x05?
It looks like, though they're calling it a bitmap, it's actually being used as an array of one-byte IDs, that are used to differentiate whole allocations.

Re: Questions about Pancakes' heap implementation with bitma

Posted: Fri Feb 05, 2021 12:08 pm
by j4cobgarby
justinian wrote:
j4cobgarby wrote: - Why, when initialising a new block, are the bytes in the bitmap set to 0x05?
It looks like, though they're calling it a bitmap, it's actually being used as an array of one-byte IDs, that are used to differentiate whole allocations.
Oh, I see, do you mean by the one-byte IDs that they're the thing used to represent how long each allocation is?

Re: Questions about Pancakes' heap implementation with bitma

Posted: Fri Feb 05, 2021 12:12 pm
by j4cobgarby
j4cobgarby wrote:
justinian wrote:
j4cobgarby wrote: - Why, when initialising a new block, are the bytes in the bitmap set to 0x05?
It looks like, though they're calling it a bitmap, it's actually being used as an array of one-byte IDs, that are used to differentiate whole allocations.
Oh, I see, do you mean by the one-byte IDs that they're the thing used to represent how long each allocation is?
Actually I may have just worked it out, as you said, the number in the byte distinguishes between the different allocations - got it, thanks :)