Review your favorite Linux distribution.
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, 12: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, 09:13 PM   #2
Senior Member
Registered: Jun 2004
Posts: 2,553

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

All times are GMT -5. The time now is 08:07 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