LinuxQuestions.org
Visit Jeremy's Blog.
Go Back   LinuxQuestions.org > Forums > Non-*NIX Forums > Programming
User Name
Password
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.

Notices


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

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


Hello

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
foo_bar_foo
Senior Member
 
Registered: Jun 2004
Posts: 2,553

Rep: Reputation: 53
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.
 
  


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
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 System.map file? and why do we need it? concoran Linux - General 9 11-18-2001 10:42 PM

LinuxQuestions.org > Forums > Non-*NIX Forums > Programming

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

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
Open Source Consulting | Domain Registration