what scenarios we set file descriptor as -1 in mmap?
<p><a href="https://stackoverflow.com/questions/258091/when-should-i-use-mmap-for-file-access">why mmap is better than read and write</a></p>

<p><a href="https://stackoverflow.com/questions/24136257/passing-1-as-file-descriptor-to-mmap">one more similar post</a></p>

<p>My question is as follows:
There are certain scenarios people using mmap rather than to read from files. One such code is:</p>

<pre><code> *mapping = mmap(NULL, *mapping_size, PROT_READ | PROT_WRITE,
      MAP_POPULATE | MAP_ANONYMOUS | MAP_PRIVATE, -1, 0);
</code></pre>

<p>The above code tries to allocate huge amount of memory. 
I want to know what is mmap does in this case, how it works. Everyone talks about advantage of mmap wrt files. But these kinds of code where fd is set to -1 are frequent. What does it mean, what are the advantages of doing so.? I wish someone can clear my doubt, which I couldn't ask completely due to ambiguity.</p>

<p>Thank you</p>