c++ - the speed of read and write system call on shared memory object in comparison with one of memcpy -


i' using shared memory (with semaphore) communicating between 2 processes: fist, open shared memory object using call:

int fd = shm_open("name") [http://linux.die.net/man/3/shm_open] 

second, map shared mem object adress space using call:

void* ptr = mmap(..fd..) [http://linux.die.net/man/2/mmap2] 

however, want use epoll in conjunction shared memory file descriptor==> don't use mmap anymore, , instead, using epoll monitoring, , add, write function direct access shared memory using fd (shared memmory file descriptor)

my question that: how speed of direct reading , writing on shared memory object in comparison memcpy on pointer returned mmap?

read(fd, buffer) vs memcpy(des, source, size) //??? 

hope see answer! thanks!

read syscall , implies privilege transition implies address space manipulation (mmu) , kernel call memcpy provided buffer destination address. same thing (call memcpy) adding 2 expensive operations (privilege transitions) , cheap 1 (finding destination address).

we can conclude read/write slower.


Comments

Popular posts from this blog

c# - DetailsView in ASP.Net - How to add another column on the side/add a control in each row? -

javascript - firefox memory leak -

Trying to import CSV file to a SQL Server database using asp.net and c# - can't find what I'm missing -