Difference between Areas and mmap

I was researching ways to share memory in different contexts (specifically user-space and kernel). I came across two ways, one is mmap() which is in the POSIX standard, and another is Areas in Haiku. Both are fairly similar according to me, just that mmap() supports file descriptors. Are there any advantages of Areas over mmap()?

EDIT: Never mind, the mmap() implementation uses Areas.

Yep, areas is the “native” api. mmap is required for compatibility with posix :slight_smile:
You can use either

1 Like

Indeed it does. On Haiku, all virtual memory regions in an address are areas, there are merely different kinds of them: private areas, shared areas, file-backed areas…

Internally the different kinds of areas are implemented with different kinds of VM objects, which represent physical memory.

So, you can create an area with mmap or create_area, and then interact with it using either the POSIX routines (mprotect, …) or Haiku routines (set_area_protection, …) and it makes no difference.

5 Likes