mmap

Does mmap share memory with all processes?

≯℡__Kan透↙ 提交于 2019-12-12 09:50:55
问题 When I do this : myProgram.h myProgram.c struct PipeShm { // all my fields // more // ... }; struct PipeShm myPipe = { /* initialization for all fields */ }; struct PipeShm * sharedPipe = &myPipe; void func() { sharedPipe = mmap (NULL, sizeof * sharedPipe, PROT_READ | PROT_WRITE,MAP_SHARED | MAP_ANONYMOUS, -1, 0); } When I mmap the pointer sharedPipe , if I invoke from main() any methods from myProgram code, would all processes share the exact shared memory that I shared with myPipe struct?

Why people say mmap by MappedByteBuffer is faster?

我们两清 提交于 2019-12-12 09:20:27
问题 I think mmap is not fast as using virtual memory, it still has harddisk I/O. But many people on Internet say it's fast, but no reason. In my test, I read a file using BufferedReader andMappedByteBuffer, the first one is faster. 回答1: A MappedByteBuffer is suitable for reading binary files that are not read sequentially. An example is reading a database index file containing tree data-structures with file offsets to other parts of the file. In this case, you are continually seeking forwards and

Why does mmap() use MAP_FAILED instead of NULL?

有些话、适合烂在心里 提交于 2019-12-12 08:23:18
问题 Does anybody know why mmap() returns MAP_FAILED instead of NULL? It seems that MAP_FAILED is (void*)-1 on most systems. Why doesn't mmap() just use NULL instead? I know that address 0x0 is technically a valid memory page, whereas (void*)-1 will never be a valid page. Yet my guess is that mmap() will never actually return page 0x0 in practice. On Windows, for example, VirtualAlloc() returns NULL on error. Is it safe to assume that mmap() will never return 0x0? Presumably a successful call to

what is the size limit for mmap

自古美人都是妖i 提交于 2019-12-12 08:12:25
问题 I am using mmap() to map a shared memory object to a process. My question has two parts: 1) what is the size limit for mmap() to a linux process? (is there such limit?) 2) after the process running a while, I think the process virtual memory address space will be somehow fragmented. Will this impact the max size I can do mmap() in this process? The linux kernel used is 2.6.27 . The size of the shared memory object is around 32MB. I am trying to access what is the possibility that mmap() fails

MMAP fails in attempt to double buffer framebufer

牧云@^-^@ 提交于 2019-12-12 04:59:52
问题 I am trying to implement a double buffer using ioctl(fd, FBIOPAN_DISPLAY... my single buffer code works fine screensize = vinfo.xres * vinfo.yres * vinfo.bits_per_pixel / 8; fbp = (char*)mmap(0, screensize, PROT_READ | PROT_WRITE, MAP_SHARED, fbfd, 0); when I try to increase the "length parameter" by using screensize*2, the mmap fails with EINVAL . I think it doesn't like my length parameter. The screen size for a single buffer is 6,220,800 and for the double buffer is 12,441600. This is an

wx.TextCtrl.LoadFile()

喜夏-厌秋 提交于 2019-12-12 04:00:03
问题 I am trying to display search result data quickly. I have all absolute file paths for files on my network drive(s) in a single, ~50MB text file. The python script makes a single pass over every line in this file [kept on the local drive] in a second or less, and that is acceptable. That is the time it takes to gather results. However, the results are given in a wx.TextCtrl widget. Appending them line by line to a wx TextCtrl would be ridiculous. The best method I have come up with is to write

How to read from /write to anonymous shared mapping?

最后都变了- 提交于 2019-12-12 02:27:01
问题 Attempting to write a message to anonymous shared memory with a child process, terminate it. Then have the message read by the parent. I have seen examples for mapping input & output files using file descriptors obtained through read & write calls. But do not know how to approach this correctly. int main(void) { char *shared; int status; pid_t child; shared = mmap(0, sizeof(int) , PROT_READ | PROT_WRITE, MAP_SHARED | MAP_ANON, -1, 0); if (shared == MAP_FAILED) { perror("mmap"); return 1; }

Unlimited stack cannot grow beyond the initial 132KiB if MAP_FIXED involved?

不羁的心 提交于 2019-12-11 19:08:43
问题 I'm running some experiments with stack and the following got me stuck. It can be seen that Linux has initial [stack] mapping 132KiB in size. In case of ulimit -s unlimited we can expand the stack any further if we adjust rsp accordingly. So I set ulimit -s unlimited and ran the following program: PAGE_SIZE equ 0x1000 ;mmap staff PROT_READ equ 0x01 PROT_WRITE equ 0x02 MAP_ANONYMOUS equ 0x20 MAP_PRIVATE equ 0x02 MAP_FIXED equ 0x10 ;syscall numbers SYS_mmap equ 0x09 SYS_exit equ 0x3c section

unable to allocate memory error on mac os x - java(xx,xx) malloc: *** mmap(size=XX) failed (error code=12)

不问归期 提交于 2019-12-11 18:27:17
问题 I believe it's a general issue but if it helps I'm running LucidDB database (0.9.4) on Mac OS X 10.8 with 16GB RAM. The database software is written mainly in Java with some parts in C++. When I increased buffer pool size to 1GB I got the following error. java(669,0xfc621000) malloc: * mmap(size=16777216) failed (error code=12) error: can't allocate region ** set a breakpoint in malloc_error_break to debug I believe that buffer pool uses shared memory so I increased max available shared

Access PCI memory BAR with low latency (Linux)

醉酒当歌 提交于 2019-12-11 17:47:37
问题 Background: I have a PCI card, which is basically a clock. It gets the time by GPS and saves the current time in a certain register. Goal: I want to read a limited number of registers/bytes (for example the current time) over and over again, with the lowest possible latency . (The clock provides very high precision and I think I will loose precision the higher the latency is.). The operating system is RedHat. The programming language is C/C++. I also want to write to the device memory,