Summary
Enable the mmap C extension module, which provides memory-mapped file I/O support.
Current State
Commented out in Modules/Setup.stdlib:
Why Enable It
mmap enables efficient file I/O by mapping files directly into memory
- Used by
multiprocessing.shared_memory for shared memory segments
importlib can use mmap for faster module loading
- Many data processing libraries rely on mmap for large file handling
ctypes may use mmap internally
Work Required
- Uncomment in
Modules/Setup.stdlib:
- Nanvix POSIX syscall requirements:
mmap(addr, length, prot, flags, fd, offset) — map files/memory
munmap(addr, length) — unmap memory
msync(addr, length, flags) — synchronize mapped memory
madvise(addr, length, advice) — memory advisory (optional)
mremap(old_addr, old_size, new_size, flags) — resize mapping (Linux-specific, optional)
- Required headers:
<sys/mman.h>
- Protection flags needed:
PROT_READ, PROT_WRITE, PROT_EXEC
- Mapping flags needed:
MAP_SHARED, MAP_PRIVATE, MAP_ANONYMOUS
- Build and test:
python -c "import mmap; print(mmap.PAGESIZE)"
POSIX API Dependencies
| API |
Purpose |
mmap() |
Create memory mapping |
munmap() |
Remove memory mapping |
msync() |
Flush changes to disk |
madvise() |
Memory usage hints (optional) |
mprotect() |
Change protection (optional) |
Complexity
High — requires Nanvix to support virtual memory mapping syscalls. This is a fundamental OS capability.
Source Files
Summary
Enable the
mmapC extension module, which provides memory-mapped file I/O support.Current State
Commented out in
Modules/Setup.stdlib:Why Enable It
mmapenables efficient file I/O by mapping files directly into memorymultiprocessing.shared_memoryfor shared memory segmentsimportlibcan use mmap for faster module loadingctypesmay use mmap internallyWork Required
Modules/Setup.stdlib:mmap(addr, length, prot, flags, fd, offset)— map files/memorymunmap(addr, length)— unmap memorymsync(addr, length, flags)— synchronize mapped memorymadvise(addr, length, advice)— memory advisory (optional)mremap(old_addr, old_size, new_size, flags)— resize mapping (Linux-specific, optional)<sys/mman.h>PROT_READ,PROT_WRITE,PROT_EXECMAP_SHARED,MAP_PRIVATE,MAP_ANONYMOUSpython -c "import mmap; print(mmap.PAGESIZE)"POSIX API Dependencies
mmap()munmap()msync()madvise()mprotect()Complexity
High — requires Nanvix to support virtual memory mapping syscalls. This is a fundamental OS capability.
Source Files
Modules/mmapmodule.c