I want sample code in c that will use mmap to get memory and then allocate to the the processes that need it.
Ideally it should have two funtions, one which is a process that asks for memory and the other which allocates memory using mmap.
I have started out, but am not able to get a clear picture.
void * allocation;
allocation = (caddr_t) mmap(0, 5000, PROT_READ|PROT_NONE, MAP_PRIVATE, Somefd, 0);
mmap() creates a new mapping in the virtual address space of the calling process so i dunt understand why file discriptor comes into the picture.
And can the above mentioned be implemented without fd or any files coming into picture?
how will the process which needs memory be given the chunk allocated by mmap?
Is it possible to mmap an area of memory and assign that memory to requesting processes?