1

I would like to build a memory allocator to manage a large chunk of non-shared, linear address space (e.g. 32GB). I need to run this on the Big-3 operating systems, but I can live with having OS-specific code.

Functionality desired:

  • At start, acquire a 2^N byte contiguous region of virtual address space aligned on a 2^N byte boundary
  • Initially, the entire region should be inaccessible (i.e. touching any address within this region should result in that OS's equivalent of a SEGV)
  • Over time, from the base of this region (the lowest address), I will grow the portion that should be made accessible (i.e. allocate backing store, provision PTEs)
  • It is acceptable, while running, to encounter a failure due to backing store exhaustion

Bonus points:

  • It is desirable that, initially, no backing store be reserved
  • Unprovisioning the entire region without releasing the address space
  • Encourage use of larger pages and TLB entries

Questions:

  • I know that I can implement this scheme using mmap on Linux. Is it doable on Win64 and MacOS?
  • If yes, what primitives / system calls should I be looking at?
  • How can I best achieve 2^N byte alignment when initially acquiring address space?
John Yates
  • 1,027
  • 1
  • 7
  • 18
  • 1
    On Windows, you can use VirtualAlloc to reserve address space or commit memory into it. VirtualAllocEx lets you pick the starting address. – Raymond Chen Sep 24 '21 at 20:17

0 Answers0