[LCP] mapping memory
Mark Farnell
mark.farnell at gmail.com
Tue Nov 4 12:44:02 EST 2008
I mean different logical address.
In a process, suppose I malloc a piece a memory
#define SIZE 1024
void *a = malloc(SIZE);
Are there any functions which produces a logical mapping of the chunk
I've malloced on a *different* address space (but in fact point to the
same chunk)
void *b = map(a, size);
so that b is the base address of a different block (address looks
different to a), yet if a thread changes the content pointed to b, it
actually maps to the block pointed to by a.
The application is that I have a process which spawns multiple POSIX
threads. The process malloc's a piece of memory. Then what I intend
to do is that for each thread, map that piece of memory to a different
address space, each mapping can have individual mprotect operations
that does not affect other mappings owned by other threads.
However if a mapping is written to, it actually writes to the piece of
memory malloc'ed by the master.
So memcpy etc will *not* do the job. I am not asking how to copy contents.
Can this be done?
Thanks!
Mark
>hi mark,
>Mark Farnell wrote:
>> In a Linux process, I have malloc'ed a piece of memory. Within this
>> process, are there any ways to map this chunk of memory to a different
>> address?
>what do you mean by "a different address"?
>regards,
>kim
>--
>Operating Systems, Services and Operations
>Information Technology Services, The University of Adelaide
>kim.hawtin at adelaide.edu.au
More information about the linuxCprogramming
mailing list