I have a homework to compare mmap() and read(). while I've read some webpages, I didn't understand what exactly each does, especially mmap()!
now there are some questions that I didn't understand yet...
- what does mmap exactly does? does it bring the whole file to memory? or it only fetches the address to address space of the process? 2.does mmap() work due to demand paging?
- what does read() do exactly? what chunk is best for a file? (we know the file-size)
- when should we use mmap()? when read()?
as I mentioned above, the aim is to compare these two system calls (right?!). for this goal, I counted the number of printable characters and spaces in three files: 800MB , 8 MB , 38 kB. here is the result: (they show time for counting printable characters and spaces for each file) why are those up and downs for? in other words, why mmap is not always better? (it seems it works best usually!)