lundi 29 juin 2015

mmap() and read(). what are they? cons and pros of each one?

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...

  1. 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?
  2. what does read() do exactly? what chunk is best for a file? (we know the file-size)
  3. 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) enter image description here why are those up and downs for? in other words, why mmap is not always better? (it seems it works best usually!)

Aucun commentaire:

Enregistrer un commentaire