LinuxQuestions.org
Latest LQ Deal: Linux Power User Bundle
Go Back   LinuxQuestions.org > Forums > Linux Forums > Linux - Newbie
User Name
Password
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!

Notices


Reply
  Search this Thread
Old 10-21-2011, 07:17 AM   #1
xerox
Member
 
Registered: Mar 2011
Posts: 43

Rep: Reputation: 0
Post sample code with mmap


Hi,

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.

Code:
 
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 02:20 AM.
 
  


Reply


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 09:01 AM
MRG Sample Code xingkia Programming 0 05-05-2008 09:43 PM
Perl: What's this mean? (Code sample) Benr Programming 5 10-23-2004 08:20 AM
Open Firmware code for booting OS from SATA : sample code available somewhere ? drsparikh Linux - Hardware 0 03-12-2004 12:16 PM
Any sample code of how to use Rand_seed() cybercop12us Programming 0 04-03-2003 08:25 AM


All times are GMT -5. The time now is 10:22 AM.

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