Memory Management
The memory management in this first kernel release is quite simple but very efficent as it has a small overhead. The memory is allocated in dynamically sized blocks that have the following structure in physical memory:
----------------- Offset | PID of Owner | 0x00 ----------------- | Size in bytes | 0x01 ----------------- | | 0x03 (0x05) | Memory space | | | ------------------- ------------------- | | -----------------The first byte of the memory block contains the PID of the process owning the block, this is the process the memory block was allocated by. If the PID is '254', the block is free, if it is '255' the block has been reserved by a process for dynamic memory block resizing (remalloc). Reserved memory blocks will be used for regular memory allocating (malloc) when there is not enough contigious, free memory. The rest of the block is the memory space whose adress is returned by the malloc kernel function. The memory block header is defined in the MEMBINFO struct:
struct s_mem { unsigned char pid; unsignedlong size; };