Skip to content
This repository has been archived by the owner on May 29, 2018. It is now read-only.

Memory management

Noxer edited this page Jan 31, 2013 · 1 revision

This page describes the internal structure of the memory management in Atlas 2.

Every process has (at least) one own memory management list. The mm list start with 0x0000 and ends with 0x0000. An entry starts with the (even) length of the entry, with the lowest bit as a allocated-flag, followed by the data of the entry and the length (with the flag). The number of data-words is always even!

0x0000 ; start of the table

0x0004 ; free entry of four words
0x1234 ; data...
0x4321
0x1111
0xFFFF
0x0004 ; end of the free entry

0x0003 ; allocated entry of two words (0x0002 & 0x0001)
0xFFFF ; data...
0x0000
0x0003 ; end of the allocated entry

0x0000 ; end of the table

When a process tries to allocate memory the mm chooses the first entry which is big enough, splits it in an allocated and free entry (if the free entry was big enough). When the mm reaches the end of the table without finding a matching entry it returns 0x0000.

A process can simply allocate memory by calling

; A = start of the mm table
; B = number of words to reserve
JSR mm_alloc
IFE A, 0x0000
SET PC, not_enough_mem

The start of the initial mm table is the first word after the process image (the code and data sections). The memory management automatically allocates new pages if there is not enough space on the existing ones.

Clone this wiki locally