Skip to content
Advertisement

Tag: mmap

trying to cause SIGSEGV in mmap

I’m trying to create a memory mapping of length greater than the underlying file. When I access pages of the mapping (which are not correspondingly mapped to a file), a SIGBUS is caused. However when I try to access the memory outside the memory mapping length, it should cause SIGSEGV (but isn’t), why is that? Answer Stopping your program and

How to increase the size of memory region allocated with mmap()

I’m allocating memory using mmap Linux syscall. Is it possible to increase the size of allocated memory region preserving its start address and contents? How to do it properly? Answer On Linux, use the mremap(2) Linux-specific system call without MREMAP_MAYMOVE to extend the existing mapping, without considering the option of remapping those physical pages to a different virtual address where

Why is MAP_GROWSDOWN mapping does not grow?

I tried to create MAP_GROWSDOWN mapping with the expectation it would grow automatically. As specified in the manual page: MAP_GROWSDOWN This flag is used for stacks. It indicates to the kernel virtual memory system that the mapping should extend downward in memory. The return address is one page lower than the memory area that is actually created in the process’s

mmap: performance when using multithreading

I have a program which performs some operations on a lot of files (> 10 000). It spawns N worker threads and each thread mmaps some file, does some work and munmaps it. The problem I am facing right now is that whenever I use just 1 process with N worker threads, it has worse performance than spawning 2 processes

c++ close a open() file read with mmap

I am working with mmap() to fastly read big files, basing my script on this question answer (Fast textfile reading in c++). I am using the second version from sehe answer : and it works just great. But if I implement it over a loop of several files (I just change the main() function name to: and then get the

Segmentation fault when maping /dev/mem

I’m trying to mmap a memory from my FPGA on a linux running on my Zedboard SoC. I can read the contents correctly using devmem on the command line, but when trying to read it through C I get a segmentation fault. The barebones code shown below throws the segmentation fault when trying to print the contents of the memory.

Advertisement