Latest LQ Deal: Complete CCNA, CCNP & Red Hat Certification Training Bundle
Go Back > Forums > Linux Forums > Linux - Newbie
User Name
Linux - Newbie This Linux forum is for members that are new to Linux.
Just starting out and have a question? If it is not in the man pages or the how-to's this is the place!


  Search this Thread
Old 10-21-2011, 06:17 AM   #1
Registered: Mar 2011
Posts: 43

Rep: Reputation: 0
Post sample code with mmap


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?

Last edited by xerox; 10-24-2011 at 01:20 AM.


Thread Tools Search this Thread
Search this Thread:

Advanced Search

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is Off
HTML code is Off

Similar Threads
Thread Thread Starter Forum Replies Last Post
USB, how to R/W to port, sample C code? bapigoo9 Linux - Newbie 6 11-25-2008 08:01 AM
MRG Sample Code xingkia Programming 0 05-05-2008 08:43 PM
Perl: What's this mean? (Code sample) Benr Programming 5 10-23-2004 07:20 AM
Open Firmware code for booting OS from SATA : sample code available somewhere ? drsparikh Linux - Hardware 0 03-12-2004 11:16 AM
Any sample code of how to use Rand_seed() cybercop12us Programming 0 04-03-2003 07:25 AM > Forums > Linux Forums > Linux - Newbie

All times are GMT -5. The time now is 09:59 AM.

Main Menu
Write for LQ is looking for people interested in writing Editorials, Articles, Reviews, and more. If you'd like to contribute content, let us know.
Main Menu
RSS1  Latest Threads
RSS1  LQ News
Twitter: @linuxquestions
Facebook: linuxquestions Google+: linuxquestions
Open Source Consulting | Domain Registration