Questions about Pancakes' heap implementation with bitmaps

Question about which tools to use, bugs, the best way to implement a function, etc should go here. Don't forget to see if your question is answered in the wiki first! When in doubt post here.
Post Reply
j4cobgarby
Member
Member
Posts: 64
Joined: Fri Jan 26, 2018 11:43 am

Questions about Pancakes' heap implementation with bitmaps

Post 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?
User avatar
justinian
Posts: 19
Joined: Mon Apr 23, 2018 6:25 pm
Location: San Francisco

Re: Questions about Pancakes' heap implementation with bitma

Post 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.
Developing: jsix - UEFI-booted x64 kernel
j4cobgarby
Member
Member
Posts: 64
Joined: Fri Jan 26, 2018 11:43 am

Re: Questions about Pancakes' heap implementation with bitma

Post 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?
j4cobgarby
Member
Member
Posts: 64
Joined: Fri Jan 26, 2018 11:43 am

Re: Questions about Pancakes' heap implementation with bitma

Post 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 :)
Post Reply