Hasty Briefsbeta

Bilingual

DOS Memory Management

3 days ago
  • #Memory Management
  • #Retro Computing
  • #DOS
  • DOS memory management was simple but had pitfalls, evolving from DOS 1.x with no explicit support to DOS 2.0 introducing ALLOC, DEALLOC, and SETBLOCK functions.
  • Memory blocks in DOS are managed in 16-byte paragraphs, prefixed by a Memory Control Block (MCB) with 'M' or 'Z' signatures indicating valid or last blocks.
  • DOS coalesces free memory blocks during ALLOC calls to prevent fragmentation, with DEALLOC performing no coalescing and SETBLOCK coalescing subsequent free blocks.
  • DOS 2.11 introduced AllocOper (INT 21h/58h) for memory allocation strategies (first fit, best fit, last fit), undocumented until DOS 5.0.
  • DOS 5.0 enhanced memory management with UMB (Upper Memory Block) support, allowing allocation strategies to include conventional memory, UMBs first, or UMBs only.
  • Notable quirks include zero-sized memory blocks, SETBLOCK changing block ownership, and DOS 5.0's bug where SETBLOCK resizes to maximum available size on failure.
  • DOS memory management's simplicity and quirks stem from early design constraints, with later versions adding complexity for UMB support and allocation strategies.