Skip to content
Advertisement

Tag: mmap

can /proc/self/exe be mmap’ed?

Can a process read /proc/self/exe using mmap? This program fails to mmap the file: Answer You are making 2 mistakes here: Mapped size must be > 0. Zero-size mappings are invalid. You have to specify, if you want to create a shared (MAP_SHARED) or a private (MAP_PRIVATE) mapping. The following should work for example: If you wish to map the

ARM linux userspace gpio operations using mmap /dev/mem approach (able to write to GPIO registers, but fail to read from them)

Kernel version 3.12.30-AM335x-PD15.1.1 by PHYTEC. If I use the /sys/class/gpio way, I can see that the button input pin (gpio103 of AM3359) value changes from 0 to 1. Following the this exercise http://elinux.org/EBC_Exercise_11b_gpio_via_mmap and executing the below command for reading gpio pins usig /dev/mem approach: (base of gpio bank 3 which is 0x481ae000 + 0x13c dataout offset) I get the

Can mmap and O_DIRECT be used together?

As I understand it, when you mmap a file you are basically mapping the pages from the page cache for that file directly into your process, and when you use O_DIRECT you are bypassing the page cache. Does it ever make sense to use the two together? If my understanding is right how would it even work? mmap seems to

Write-only mapping a O_WRONLY opened file supposed to work?

Is mmap() supposed to be able to create a write-only mapping of a O_WRONLY opened file? I am asking because following fails on a Linux 4.0.4 x86-64 system (strace log): The errno equals EACCESS. Replacing the open-flag O_WRONLY with O_RDWR yields a successful mapping. The Linux mmap man page documents the errno as: Thus, that behaviour is documented with the

mmap vs sbrk, performance comparison

Which of these calls is faster on average? I’ve heard that mmap is faster for smaller allocations but I haven’t heard a comparison of either. Any information on performance for these would be nice. Answer You should tag this with a particular implementation (like linux) since the answer surely varies by implementation. For now I’ll assume Linux since it’s the

Advertisement