New upload: Fragmentation demo of heap memory manager in banked ram

All aspects of programming on the Commander X16.
Post Reply
User avatar
svenvandevelde
Posts: 488
Joined: Wed Dec 23, 2020 6:30 am
Location: Belgium, Antwerpen

New upload: Fragmentation demo of heap memory manager in banked ram

Post by svenvandevelde »




Fragmentation demo of heap memory manager in banked ram




View File






A demo showing a heap memory manager being functional, dynamically allocating and freeing memory blocks of various sizes in banked memory of the CX16.






 
KICKC home page by Jesper Gravgaard.
My KICKC alpha with Commander X16 extensions.
ZeroByte
Posts: 714
Joined: Wed Feb 10, 2021 2:40 pm

New upload: Fragmentation demo of heap memory manager in banked ram

Post by ZeroByte »


Can you go into a little more detail about what it is I'm looking at? I'm interested in this library as dealing with HiRam is quite a PITA. What's the narrow band at the top? Low RAM? Is data being moved between Hi and Lo RAM?

User avatar
svenvandevelde
Posts: 488
Joined: Wed Dec 23, 2020 6:30 am
Location: Belgium, Antwerpen

New upload: Fragmentation demo of heap memory manager in banked ram

Post by svenvandevelde »



On 12/22/2021 at 5:27 PM, ZeroByte said:




Can you go into a little more detail about what it is I'm looking at? I'm interested in this library as dealing with HiRam is quite a PITA. What's the narrow band at the top? Low RAM? Is data being moved between Hi and Lo RAM?



All data is managed in hi-ram. That is banked ram. From address 0x2000 till 0x44000, assuming that the banked ram is a continuous space. (We both know it is not). So divide 0x44000 / 0x2000, which gives 22 banks. However the index is managed in bank 1 of bram, so 20 banks of 0x2000 bytes are used for the heap. Bank 0 is unused. 

The heap allocation starts from the top moving down. 

I'll post the source code of the heap manager later once I'm behind my laptop. 

I'm stil optimizing it though...

Sven

KICKC home page by Jesper Gravgaard.
My KICKC alpha with Commander X16 extensions.
User avatar
svenvandevelde
Posts: 488
Joined: Wed Dec 23, 2020 6:30 am
Location: Belgium, Antwerpen

New upload: Fragmentation demo of heap memory manager in banked ram

Post by svenvandevelde »



On 12/22/2021 at 5:27 PM, ZeroByte said:




Can you go into a little more detail about what it is I'm looking at? I'm interested in this library as dealing with HiRam is quite a PITA. What's the narrow band at the top? Low RAM? Is data being moved between Hi and Lo RAM?



Here you are my friend @ZeroByte

cx16-heap-test-fragmentation.c

cx16-heap.h

cx16-heap.c

The complete compiler source code can be found here in a branch:

src/main/kc/lib/cx16-heap.c · CX16_HEAP · Sven Van de Velde / kickc · GitLab

KICKC home page by Jesper Gravgaard.
My KICKC alpha with Commander X16 extensions.
User avatar
svenvandevelde
Posts: 488
Joined: Wed Dec 23, 2020 6:30 am
Location: Belgium, Antwerpen

New upload: Fragmentation demo of heap memory manager in banked ram

Post by svenvandevelde »


I have the latest updates moved to my cx16 coding area on github. Moving the heap manager out of the kickc compiler did the moment but as a side compile.

https://github.com/FlightControl-User/X16_Code/blob/main/cx16_lib/cx16-heap.c

An open work item is to be able to configure that allocated blocks are not crossing $a000 - $buff bank boundaries. This is important for data structures. The data elements in the structure must be stored in sequential memory space.  For bitmap data such boundary crossing would not be a problem though. 

For example, if at address $A008 a block would be allocated of 16 bytes, then this would require the remaining 8 to be registered as idle, and the 16 bytes to be allocated from $C000 downwards, with base $BFF0.

 

KICKC home page by Jesper Gravgaard.
My KICKC alpha with Commander X16 extensions.
User avatar
svenvandevelde
Posts: 488
Joined: Wed Dec 23, 2020 6:30 am
Location: Belgium, Antwerpen

New upload: Fragmentation demo of heap memory manager in banked ram

Post by svenvandevelde »



On 12/22/2021 at 5:27 PM, ZeroByte said:




Can you go into a little more detail about what it is I'm looking at? I'm interested in this library as dealing with HiRam is quite a PITA. What's the narrow band at the top? Low RAM? Is data being moved between Hi and Lo RAM?



Still interested?

KICKC home page by Jesper Gravgaard.
My KICKC alpha with Commander X16 extensions.
Post Reply