View the Most Wanted LQ Wiki articles.
Go Back > Forums > Non-*NIX Forums > Programming
User Name
Programming This forum is for all programming questions.
The question does not have to be directly related to Linux and any language is fair game.


  Search this Thread
Old 01-16-2006, 01:00 PM   #1
LQ Newbie
Registered: Jan 2006
Posts: 13

Rep: Reputation: 0
> File Mapping And Pthreads, How to map file in memory?


I am trying to map a file in memory to use with pthreads (read/write blocks), but when I try to use a easy funcion to get void pointer, returned pointer is diferent each time.

The first place, the programs calls mmap with MAP_SHARED,

if ((source = mmap (0, fst1.st_size, PROT_READ | PROT_WRITE, MAP_SHARED, file, 0)) == (void *) -1)
perror ("Error ");
return (fail);

Why return different pointer each time?

Another method to easy manage of maped files like AIX file_ptr=shmat (fd, 0, SHM_MAP); ?

Thanks in advance.
Old 01-16-2006, 10:13 PM   #2
Senior Member
Registered: Jun 2004
Posts: 2,553

Rep: Reputation: 51
you have put the argument 0 or NULL as the first argument to mmap which is a way of saying just choose any available start address.


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
fc3 file map ? einstien Fedora 2 03-03-2005 11:12 AM
SYSERR(root): hash map "generics": missing map file /etc/mail/genericstable.db? singying304 Linux - Networking 4 02-28-2005 07:49 AM
Help!?! RH 8 Memory Mapping -High Memory-Virtural Memory issues.. Merlin53 Linux - Hardware 2 06-18-2003 05:48 PM
what's this map file aditya Linux - Newbie 1 10-17-2002 02:59 PM
What is file? and why do we need it? concoran Linux - General 9 11-18-2001 10:42 PM

All times are GMT -5. The time now is 05:05 PM.

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