Weighing in at about 380 bytes, Itsy should port well to tiny architectures.
Memory Control Blocks
Each block of memory is preceded by a memory control block which is 32 bytes long. The blocks of memory are arranged as a circular linked list. The first memory control block resides in segment 050h.
The task switcher is called by the timer interrupt. First it checks whether switching is disabled. If not:
- disable switching
- save the registers of the current task on the stack
- save the stack pointer of the current task in it's MCB
- find the next MCB with an available task
- restore the new task's stack pointer and registers
- enable switching and transfer control to the new task
Called with DS = MCB of memory to free. Deallocated memory is wiped with 0CCh.
Switching is disabled while the memory structure is being modified. If the memory being deallocated contains a process, it is removed from the process queue. If adjacent memory blocks are marked as free, the blocks are combined.
Called with AX = number of paragraphs required. Returns DS = location of memory, or DS = 0 if no memory available. Switching is disabled while the memory structure is being modified. Allocation uses a simple best fit algorithm.
Simply sets up the timer interrupt.