|
|
|
|
|
|
| Author |
Message |
Frank Cusack *nix forums Guru Wannabe
Joined: 02 Mar 2005
Posts: 215
|
Posted: Tue Dec 06, 2005 1:08 am Post subject:
Re: mmap question
|
|
|
Probably because of MAP_PRIVATE?
On 2 Dec 2005 14:27:16 -0800 dinakar.dhurjati@gmail.com wrote:
| Quote: | Tried it but it returns two differnt physical pages even when I use the
same offset in the file.
e.g. the following program returns 6 and 5 (while I want 6 and 6 ).
---------------------------------------code--------------------------------------------
#include <sys/mman.h
#include <sys/types.h
#include <sys/stat.h
#include <fcntl.h
#include <unistd.h
#include <sys/ipc.h
#include <sys/shm.h
main() {
unsigned PageSize = sysconf(_SC_PAGESIZE);
int sd;
void *pa2, *pa3, *pa;
sd = open("/dev/zero",O_CREAT|O_RDWR);
pa = mmap(0, PageSize, PROT_READ|PROT_WRITE, MAP_PRIVATE, sd, 0);
*(char *)pa = 5;
pa3 = mmap(0, PageSize, PROT_READ|PROT_WRITE, MAP_PRIVATE, sd, 0);
*(char *)pa3 = 6;
printf("%d \n",*(char *)pa3);
printf("%d \n",*(char *)pa);
}
--------------------------------------------------------------------------------------------
Thanks
Dinakar |
|
|
| Back to top |
|
 |
dinakar.dhurjati@gmail.co *nix forums beginner
Joined: 02 Dec 2005
Posts: 4
|
Posted: Fri Dec 02, 2005 10:27 pm Post subject:
Re: mmap question
|
|
|
Tried it but it returns two differnt physical pages even when I use the
same offset in the file.
e.g. the following program returns 6 and 5 (while I want 6 and 6 ).
---------------------------------------code--------------------------------------------
#include <sys/mman.h>
#include <sys/types.h>
#include <sys/stat.h>
#include <fcntl.h>
#include <unistd.h>
#include <sys/ipc.h>
#include <sys/shm.h>
main() {
unsigned PageSize = sysconf(_SC_PAGESIZE);
int sd;
void *pa2, *pa3, *pa;
sd = open("/dev/zero",O_CREAT|O_RDWR);
pa = mmap(0, PageSize, PROT_READ|PROT_WRITE, MAP_PRIVATE, sd, 0);
*(char *)pa = 5;
pa3 = mmap(0, PageSize, PROT_READ|PROT_WRITE, MAP_PRIVATE, sd, 0);
*(char *)pa3 = 6;
printf("%d \n",*(char *)pa3);
printf("%d \n",*(char *)pa);
}
--------------------------------------------------------------------------------------------
Thanks
Dinakar |
|
| Back to top |
|
 |
Frank Cusack *nix forums Guru Wannabe
Joined: 02 Mar 2005
Posts: 215
|
Posted: Fri Dec 02, 2005 9:52 pm Post subject:
Re: mmap question
|
|
|
On 2 Dec 2005 12:10:57 -0800 dinakar.dhurjati@gmail.com wrote:
| Quote: | I do know how to get the same effect by mmapping an existing file at
the same offset multiple times, but I really don't want to have any
backing store for the mmap.
|
How about mapping /dev/zero?
-frank |
|
| Back to top |
|
 |
dinakar.dhurjati@gmail.co *nix forums beginner
Joined: 02 Dec 2005
Posts: 4
|
Posted: Fri Dec 02, 2005 8:10 pm Post subject:
mmap question
|
|
|
[I posted this on unix.solaris as well, but thought people here might
know]
Hello,
I have a question on using mmap on Solaris. Any help is appreciated.
Is there a way to map multiple virtual pages to the same physical page
with in a process?
I need this capability for a research project of mine. I know how to do
this in Linux, courtesy http://lkml.org/lkml/2004/1/10/226 , but it
uses mremap, which is not
available on Solaris. Does there exist anything similar on Solaris and
other unices?
I do know how to get the same effect by mmapping an existing file at
the same offset multiple times, but I really don't want to have any
backing store for the mmap. I want to be able to do MAP_ANON and
then have it also map to a different virutal page. Any pointers?
Thanks
Dinakar |
|
| Back to top |
|
 |
Google
|
|
| Back to top |
|
 |
|
|
The time now is Sat Nov 22, 2008 10:39 am | All times are GMT
|
|
Ringtones | Business Sales | iPhone Reviews | Massage Classes | Remortgaging
|
|
Copyright © 2004-2005 DeniX Solutions SRL
|
|
|
|
Other DeniX Solutions sites:
Unix/Linux blog |
electronics forum |
medicine forum |
science forum |
|
|
Privacy Policy
|
Powered by phpBB © 2001, 2005 phpBB Group
|
|