I wish to ask whether is it possible to implement an mread() function using only system calls such as read() and write(). I know that the standard C library functions such as fread() and fwrite() use a type of buffer to read. I want to do the same but this time I want to read() and write() from a buffer to a memory mapped region and vice versa.
For example my mread() wants to read from memory map and store into buffer. Does it make sense to create a new fd just to use it as my TEMPORARY buffer. Then I use read() to read from memory mapped region into the fd..and then use write() to store the contents in fd into my actual buff.
I hope I was clear :) ..Thank you for your help!
相关问题
- Multiple sockets for clients to connect to
- Is shmid returned by shmget() unique across proces
- What is the best way to do a search in a large fil
- glDrawElements only draws half a quad
- how to get running process information in java?
Unfortunately, not very. But it sounds like you want to use the
pipe
system call. It opens two fds. Whatever's written on the write end can be read on the read end. If you're doing all of this in a single thread you have to be careful though, because you might run out of buffer space and the read/write call will then hang indefinitely.