1

As the title says, how can I find a free block to be allocated at the highest virtual address using only the POSIX API?

moatPylon
  • 2,103
  • 1
  • 15
  • 22
  • The whole point of virtual memory is that it doesn't matter what address you get - what are you trying to do? – Carl Norum Aug 20 '10 at 23:48
  • I'd like to use the adress range which is less likely to be used by most virtual memory 'users' (dynamic memory allocators and the OS dynamic loader, for example). Figured it's more likely to be the higesh adresses, thus the question. – moatPylon Aug 21 '10 at 00:12

1 Answers1

1

I would perform a binary search: using mmap with MAP_FIXED, verify whether a page can be mapped. Before testing a page, try msync to check whether the page is currently mapped already.

Martin v. Löwis
  • 124,830
  • 17
  • 198
  • 235