[Oberon] PO2013 - Show Heap Blocks
joerg.straube at iaeth.ch
Tue Jun 23 11:32:26 CEST 2020
Making a drawing might help.
For your drawing, assume the following declarations were done:
FreeBlock = POINTER TO BlockInfo;
BlockInfo = RECORD
size: INTEGER; (* 0 *)
mark: INTEGER; (* 4 *)
next: FreeBlock (* 8 *)
list0, list1, list2, list3: FreeBlock;
1) draw the states if all listX immediatly after Init() is called
2) draw the states of all listX during the first call to New() with size 32. When analyzing this step you will see that ALL lists will be modified somehow...
> Am 23.06.2020 um 11:47 schrieb Paul Reed <paulreed at paddedcell.com>:
> Hi Tomas,
>> Trying to read heap allocation code...
>> list3 points to the last free 32-block, it is a chain of 32-blocks
>> going back to HeapOrg(60000H)
> Each free list is a chain of blocks that is terminated with a next pointer of NIL (ie a singly-linked list).
> (The block at Kernel.heapOrg [80000H in the published system] may be allocated, not free, so that's not what terminates the list.)
>> I do not see yet, which part of the code terminates the list with 0,
>> where, when?
> In Kernel.Init, the lists are each initialised to NIL.
> Each free block which is added to the list is added at the front (head) of the list, and its next pointer points to the rest of the list (which may be NIL).
> It is possible to add items onto a singly-linked list at the other end (tail), if you keep a note of the tail, but if the order doesn't matter, it's not necessary.
> Oberon at lists.inf.ethz.ch mailing list for ETH Oberon and related systems
More information about the Oberon