Unix Programming - Do 'fork' copies the "Code" Memory space?

This is Interesting: Free IT Magazines  
Home > Archive > Unix Programming > January 2004 > Do 'fork' copies the "Code" Memory space?





You are viewing an archived Text-only version of the thread. To view this thread in it's original format and/or if you want to reply to this thread please [click here]

Author Do 'fork' copies the "Code" Memory space?
Baron

2004-01-23, 5:36 pm

1) What do the chile process 'looked like' after fork
e.g. (using virtual memory address)
"Parent process":
- code memory address: 0x1000-0x2000
- data memory address: 0x2000-0x3000
after fork, is this what the child process looked like:
"Child process":
- code memory address: 0x3000-0x4000
- data memory address: 0x4000-0x5000
or?
- code memory address: 0x1000-0x2000 (same as parent)
- data memory address: 0x3000-0x4000

2) so do the OS do "rebasing" (just like loading a DLL in Win32 where
the 'desired' memory address is not available) of the child process
because the change in the memory address?

3) In case the child got it's new Code Memory, do some OS (vfork in
*nix???) map the virtual memory address of the code memory to the SAME
physical address?

I hope I'm asking questions that make sense.

Thank you

Baron
=?iso-8859-1?q?M=E5ns_Rullg=E5rd?=

2004-01-23, 5:36 pm

baronng@astri.org (Baron) writes:
quote:

> 1) What do the chile process 'looked like' after fork
> e.g. (using virtual memory address)
> "Parent process":
> - code memory address: 0x1000-0x2000
> - data memory address: 0x2000-0x3000
> after fork, is this what the child process looked like:
> "Child process":
> - code memory address: 0x3000-0x4000
> - data memory address: 0x4000-0x5000
> or?
> - code memory address: 0x1000-0x2000 (same as parent)
> - data memory address: 0x3000-0x4000



Neither. Both code and data stay at the same address.
quote:

> 2) so do the OS do "rebasing" (just like loading a DLL in Win32 where
> the 'desired' memory address is not available) of the child process
> because the change in the memory address?



No.
quote:

> 3) In case the child got it's new Code Memory, do some OS (vfork in
> *nix???) map the virtual memory address of the code memory to the SAME
> physical address?



The fork() call duplicates the page tables and marks all of the
child's pages as copy on write. This means that, initially, both code
and data are mapped to the same physical memory as in the parent. If
a page is written to by the child, that page will be allocated a new
physical page to perform the write on. Code is read-only, so it will
never be copied. The virtual address space is never changed.

--
Måns Rullgård
mru@kth.se
Casper H.S. Dik

2004-01-23, 5:36 pm

mru@kth.se (=?iso-8859-1?q?M=E5ns_Rullg=E5rd?=) writes:
quote:

>The fork() call duplicates the page tables and marks all of the
>child's pages as copy on write. This means that, initially, both code
>and data are mapped to the same physical memory as in the parent. If
>a page is written to by the child, that page will be allocated a new
>physical page to perform the write on. Code is read-only, so it will
>never be copied. The virtual address space is never changed.



Small correction: if the page is written to by *either the parent or
the child* ....


Casper
--
Expressed in this posting are my opinions. They are in no way related
to opinions held by my employer, Sun Microsystems.
Statements on Sun products included here are not gospel and may
be fiction rather than truth.
Baron

2004-01-23, 5:36 pm

mru@kth.se (Måns Rullgård) wrote in message news:<yw1xhdyrotme.fsf@ford.guide>...
quote:

> baronng@astri.org (Baron) writes:
>
>
> Neither. Both code and data stay at the same address.
>
>
> No.
>
>
> The fork() call duplicates the page tables and marks all of the
> child's pages as copy on write. This means that, initially, both code
> and data are mapped to the same physical memory as in the parent. If
> a page is written to by the child, that page will be allocated a new
> physical page to perform the write on. Code is read-only, so it will
> never be copied. The virtual address space is never changed.



Are you talking about the case of 'vfork' instead of the old/original
'fork' implementation?(i read from the faq of the newsgroup that vfork
works like what you said, so i'd like to know the original
implementation of fork)

thank you!
=?iso-8859-1?q?M=E5ns_Rullg=E5rd?=

2004-01-23, 5:36 pm

baronng@astri.org (Baron) writes:
quote:

> mru@kth.se (Måns Rullgård) wrote in message news:<yw1xhdyrotme.fsf@ford.guide>...
>
> Are you talking about the case of 'vfork' instead of the old/original
> 'fork' implementation?(i read from the faq of the newsgroup that vfork
> works like what you said, so i'd like to know the original
> implementation of fork)



vfork doesn't even copy the page tables. After a vfork, the child
must call exec or _exit. The child is not allowed to change any data
before doing one of these.

--
Måns Rullgård
mru@kth.se
Baron

2004-01-23, 5:36 pm

> vfork doesn't even copy the page tables. After a vfork, the child
quote:

> must call exec or _exit. The child is not allowed to change any data
> before doing one of these.



Quoted from "Unix Programmer FAQ":
-----------------------the FAQ-------------------------
Some systems have a system call `vfork()', which was originally
designed as
a lower-overhead version of `fork()'. Since `fork()' involved copying
the
entire address space of the process, and was therefore quite
expensive, the
`vfork()' function was introduced (in 3.0BSD).
=============
So it seems that the 'old'/unimproved implementation of fork copy the
ENTIRE memory space (including the code memory) when doing 'fork'
in this case, do the OS 'rebase' the child?
=============

-----------------------Continue the FAQ-------------------------
The basic difference between the two is that when a new process is
created
with `vfork()', the parent process is temporarily suspended, and the
child
process borrows the parent's address space. This strange state of
affairs
continues until the child process either exits, or calls `execve()',
at
which point the parent process continues.
=============
So, copy-on-write is used in fork...
and vfork suspend the parent process...and if the child call execve,
it works like 'fork' and can call "_exit" to exit right away
=============

So....the whole Virtual Memory Address space is different for
different process?
What i mean is that, in the case of "fork" - 2 processes actually
using the same virtual memory address but different physical
address....(as you said: "Both code and data stay at the same
address")

This conflict with my previous OS knowledge that the page table is a
one-to-one mapping between the virtual address and the physicall
address in the ENTIRE OS instead of "per-process"

Thank you very much!
Andrei Voropaev

2004-01-23, 5:36 pm

On 2004-01-21, Baron <baronng@astri.org> wrote:
quote:

>
> Quoted from "Unix Programmer FAQ":
> -----------------------the FAQ-------------------------
> Some systems have a system call `vfork()', which was originally
> designed as
> a lower-overhead version of `fork()'. Since `fork()' involved copying
> the
> entire address space of the process, and was therefore quite
> expensive, the
> `vfork()' function was introduced (in 3.0BSD).
>=============
> So it seems that the 'old'/unimproved implementation of fork copy the
> ENTIRE memory space (including the code memory) when doing 'fork'
> in this case, do the OS 'rebase' the child?



Can't say for very old processors and very old OS. But if some OS wanted
to be multi-processed then it had to support fork and could not allow
'rebasing' of child. Just think about it. OS can't know where all your
pointers are and can't adjust them to the new "base".

quote:

>=============
>
> -----------------------Continue the FAQ-------------------------
> The basic difference between the two is that when a new process is
> created
> with `vfork()', the parent process is temporarily suspended, and the
> child
> process borrows the parent's address space. This strange state of
> affairs
> continues until the child process either exits, or calls `execve()',
> at
> which point the parent process continues.
>=============
> So, copy-on-write is used in fork...
> and vfork suspend the parent process...and if the child call execve,
> it works like 'fork' and can call "_exit" to exit right away



All the FAQ is trying to say is: Untill child is there parent can't run.
This avoids race conditions when child and parent update the same
physical memory. After child does exec or exit ('exit' would be really
stupid in this case, why to vfork and then just exit?) the parent can
continue working. So there's no copy-on-write here. And vfork does not
work like fork in this case. Maybe it would be simpler to think of
'fork' as a mean to allow independent actions on the memory content of
parent and 'vfork' as a mean to launch completely different process.
quote:

>=============
>
> So....the whole Virtual Memory Address space is different for
> different process?


quote:

> What i mean is that, in the case of "fork" - 2 processes actually
> using the same virtual memory address but different physical
> address....(as you said: "Both code and data stay at the same
> address")



Please, you contradict yourself. Virtual Memory Address space of child
and parent is the same. It can't be different More than that, most of
the time any process has the same address for beginning of code,
for beginning of data and for the beginning of stack.
quote:

>
> This conflict with my previous OS knowledge that the page table is a
> one-to-one mapping between the virtual address and the physicall
> address in the ENTIRE OS instead of "per-process"



I don't think there was ever one-to-one mapping between virtual address
and physical address in OS that supported multiple processes.

DOS could afford it, but DOS didn't do fork.

Andrei
=?iso-8859-1?q?M=E5ns_Rullg=E5rd?=

2004-01-23, 5:36 pm

Andrei Voropaev <avorop@mail.ru> writes:
quote:

>
> All the FAQ is trying to say is: Untill child is there parent can't run.



Rather, until the child has exec'ed or exited the parent can't run.
quote:

> This avoids race conditions when child and parent update the same
> physical memory. After child does exec or exit ('exit' would be really
> stupid in this case, why to vfork and then just exit?)



If an exec fails _exit is the proper thing to do. Note that exit() is
forbidden after a vfork, since exit() does all sorts of cleanup, like
calling atexit() handlers etc. _exit() exits immediately.
quote:

> the parent can continue working. So there's no copy-on-write
> here. And vfork does not work like fork in this case. Maybe it would
> be simpler to think of 'fork' as a mean to allow independent actions
> on the memory content of parent and 'vfork' as a mean to launch
> completely different process.



Correct.

--
Måns Rullgård
mru@kth.se
Casper H.S. Dik

2004-01-23, 5:36 pm

baronng@astri.org (Baron) writes:
quote:

>=============
>So it seems that the 'old'/unimproved implementation of fork copy the
>ENTIRE memory space (including the code memory) when doing 'fork'
>in this case, do the OS 'rebase' the child?
>=============



There was a bug in VAX microcode that made it so that the
Copy-On-Write code couldn't be made to work; so they came up
with "vfork()" becaus efork() with "copy eveything" was
horribly expensive.

But even now, vfork() is O(1) and fork() is O(n) where
n is the number of pages in the process' address space.
quote:

>=============
>So, copy-on-write is used in fork...
>and vfork suspend the parent process...and if the child call execve,
>it works like 'fork' and can call "_exit" to exit right away
>=============



Even in a child of fork() it's almost always wrong to call exit().
quote:

>So....the whole Virtual Memory Address space is different for
>different process?



The virtual addresses are all the same and the physical address
are mostly the same, except where modified by COW (some stack
pages get dirtied immediately, of course)
quote:

>What i mean is that, in the case of "fork" - 2 processes actually
>using the same virtual memory address but different physical
>address....(as you said: "Both code and data stay at the same
>address")



Same virtual, same physical unless COW.
quote:

>This conflict with my previous OS knowledge that the page table is a
>one-to-one mapping between the virtual address and the physicall
>address in the ENTIRE OS instead of "per-process"



virtual to physical is a many to one mapping.

(Many virtual addresses map to the same physical address, e.g.,
ins shared libraries are text segments)

Casper
--
Expressed in this posting are my opinions. They are in no way related
to opinions held by my employer, Sun Microsystems.
Statements on Sun products included here are not gospel and may
be fiction rather than truth.
Christopher Benson-Manica

2004-01-23, 5:36 pm

Måns Rullgård <mru@kth.se> spoke thus:
quote:

> The fork() call duplicates the page tables and marks all of the
> child's pages as copy on write. This means that, initially, both code
> and data are mapped to the same physical memory as in the parent. If
> a page is written to by the child, that page will be allocated a new
> physical page to perform the write on. Code is read-only, so it will
> never be copied. The virtual address space is never changed.



Is this true of all *nix flavors? I know it's the case with Linux.
Just wondering.

--
Christopher Benson-Manica | I *should* know what I'm talking about - if I
ataru(at)cyberspace.org | don't, I need to know. Flames welcome.
=?iso-8859-1?q?M=E5ns_Rullg=E5rd?=

2004-01-23, 5:36 pm

Christopher Benson-Manica <ataru@nospam.cyberspace.org> writes:
quote:

> Måns Rullgård <mru@kth.se> spoke thus:
>
>
> Is this true of all *nix flavors? I know it's the case with Linux.
> Just wondering.



AFAIK, yes. Maybe some ancient versions are different.

--
Måns Rullgård
mru@kth.se
Michel Bardiaux

2004-01-23, 5:36 pm

Måns Rullgård wrote:
quote:

> Christopher Benson-Manica <ataru@nospam.cyberspace.org> writes:
>
>
>
>
> AFAIK, yes. Maybe some ancient versions are different.
>



IIRC the very old nixes, like System3, did actual copies of the memory
space on fork. They did not support VM anyway, so they had no choice,
and for the same reason it is likely that MINIX did the same.

Then came BSD, and they introduced VFORK because FORK became probitively
expensive on large memory spaces; FORK was still there and still doing
full copies, but now under VM the address space could be unchanged.

At some point (these were the years when the history of Unix was most
complicated!) VFORK acquired the copy-on-write semantics. Then FORK as
it was became useless, and VFORK took completely over, including the name.

--
Michel Bardiaux
Peaktime Belgium S.A. Bd. du Souverain, 191 B-1160 Bruxelles
Tel : +32 2 790.29.41

Baron

2004-01-23, 10:33 pm

Then I have a question on windows DLL loading...
as I know there are something called "rebasing" where the desired
virtual memory address of a .DLL (can be set when compile) is not
available, the OS needs to do a 'rebasin' by changing all the memory
references in the code to a new memory base...

if different programs (in the case of fork, 2 processes can use the
same virtual memory which may points to different physical memory) can
goes into the same memory address, why loading a .dll needs
rebasing???

again, i hope i'm asking a valid question
thank you
=?iso-8859-1?q?M=E5ns_Rullg=E5rd?=

2004-01-24, 2:35 am

baronng@astri.org (Baron) writes:
quote:

> Then I have a question on windows DLL loading...
> as I know there are something called "rebasing" where the desired
> virtual memory address of a .DLL (can be set when compile) is not
> available, the OS needs to do a 'rebasin' by changing all the memory
> references in the code to a new memory base...
>
> if different programs (in the case of fork, 2 processes can use the
> same virtual memory which may points to different physical memory) can
> goes into the same memory address, why loading a .dll needs
> rebasing???



If the virtual address preferred by the dll is already in use at the
time it is loaded, it will have to be relocated to use some other
virtual memory addresses. Shared libraries in Unix systems are
typically compiled to position independent code, meaning that there
are no references to absolute addresses. These can be loaded at any
address without any extra work.

--
Måns Rullgård
mru@kth.se
Baron

2004-01-25, 12:35 pm

> If the virtual address preferred by the dll is already in use at the
quote:

> time it is loaded, it will have to be relocated to use some other
> virtual memory addresses. Shared libraries in Unix systems are
> typically compiled to position independent code, meaning that there
> are no references to absolute addresses. These can be loaded at any
> address without any extra work.




As the case in fork, as explained in this discussion thread, ppl said
that 2 processes (parent - child) would still use the same virtual
address but different physical address when one of them modified the
data space.

e.g.
int a = 1;
if (fork() == 0
{
a = 2; // --- 1
}
else
{
a = 3;// --- 2
}

originally, a is in virtual address 0x1000, physical address 0x21000
after fork, both parent and child process still use the same addresses
for both virtual and physical address
after 1 or 2, parent points to 0x1000 / 0x21000,
would child points to virtual: 0x1000 and physical: e.g. 0x31000???

if so, why rebasing is needed for different .dll?!
e.g.
if dll X loads to virtual address 0x1000 / 0x21000, dll Y can still
load to virtual address 0x1000 but different physical address (e.g.
0x31000)

I am a bit confused on the virtual/physical memory usage...

Thank you
Baron

2004-01-25, 12:35 pm

> IIRC the very old nixes, like System3, did actual copies of the memory
quote:

> space on fork. They did not support VM anyway, so they had no choice,
> and for the same reason it is likely that MINIX did the same.
>
> Then came BSD, and they introduced VFORK because FORK became probitively
> expensive on large memory spaces; FORK was still there and still doing
> full copies, but now under VM the address space could be unchanged.


So, all the VM space (e.g. 0 to 2^32 or 4G) are available for any process??
e.g. if I have 4G memory, I have process A and process B
process A use 0x0000 to 2G?
process B can also use 0x0000 to 2G?
while the OS will map
Process A: 0x0000 -> 2G to (physical) 0x0000 -> 2G
Process B: 0x0000 -> 2G to (physical) 2G - > 4G
?
quote:

>
> At some point (these were the years when the history of Unix was most
> complicated!) VFORK acquired the copy-on-write semantics. Then FORK as
> it was became useless, and VFORK took completely over, including the name.


David Schwartz

2004-01-25, 2:35 pm


"Baron" <baronng@astri.org> wrote in message
news:a9fc9c1a.0401251742.3cc010bf@posting.google.com...

quote:

> originally, a is in virtual address 0x1000, physical address 0x21000
> after fork, both parent and child process still use the same addresses
> for both virtual and physical address
> after 1 or 2, parent points to 0x1000 / 0x21000,
> would child points to virtual: 0x1000 and physical: e.g. 0x31000???


quote:

> if so, why rebasing is needed for different .dll?!
> e.g.
> if dll X loads to virtual address 0x1000 / 0x21000, dll Y can still
> load to virtual address 0x1000 but different physical address (e.g.
> 0x31000)




Rebasing is not needed when two processes try to use the same DLL in
different memory addresses, it's needed when one process wants to use two
DLLs that normally map to the same virtual address.

Suppose I make a DLL, foo.dll that normally loads to virtual address
0x1000 and you independently make a DLL, bar.dll that normally loads to
virtual address 0x1000 too. If a process has already map foo.dll and goes to
map bar.dll, bar.dll needs to be rebased.

quote:

> I am a bit confused on the virtual/physical memory usage...




Yep, it seems you are.

DS



Baron

2004-01-25, 5:34 pm

> Rebasing is not needed when two processes try to use the same DLL in
quote:

> different memory addresses, it's needed when one process wants to use two
> DLLs that normally map to the same virtual address.
>
> Suppose I make a DLL, foo.dll that normally loads to virtual address
> 0x1000 and you independently make a DLL, bar.dll that normally loads to
> virtual address 0x1000 too. If a process has already map foo.dll and goes to
> map bar.dll, bar.dll needs to be rebased.



is that a loaded .dll can be used by different processes?
I remembered that i heard it before (as dll is no unloaded immediately
after the process that use the dll ends...)

so..is that
1)
if process A loaded a .dll X and exit, .dll X won't unload
immediately,
and if process B start and load .dll X BUT the address used in .dll X
don't collide with any other .dll(s) already loaded by process B, B
will use the .dll X immediately
2)
in case process A loaded a .dll X and exit, while process B already
loaded another .dll(s) and collide with .dll X's VM address, .dll X
will be rebased to other VM address, right?
so, if process C then load .dll X again, and the address used by .dll
X (rebased by B already) collides with the .dll(s) loaded by C, C will
load another instances of .dll X and rebase it to the "free" virtual
memory address.
so there will be two instances of .dll X

am I correct?

Thank you very much!!!

quote:

> Yep, it seems you are.


Yes..I hope I can clear the confusion here so that i can help others
to clear their confusions!

Thank you very much!
Andrei Voropaev

2004-01-25, 8:34 pm

NNTP-Posting-Host: p50804cd4.dip0.t-ipconnect.de (80.128.76.212)
X-Trace: news.uni-berlin.de 1075109302 24423052 80.128.76.212 ([205467])
User-Agent: slrn/0.9.8.0 (Linux)
Xref: intern1.nntp.aus1.giganews.com comp.unix.programmer:142839

On 2004-01-26, Baron <baronng@astri.org> wrote:
quote:

>
> is that a loaded .dll can be used by different processes?
> I remembered that i heard it before (as dll is no unloaded immediately
> after the process that use the dll ends...)
>
> so..is that
> 1)
> if process A loaded a .dll X and exit, .dll X won't unload
> immediately,
> and if process B start and load .dll X BUT the address used in .dll X
> don't collide with any other .dll(s) already loaded by process B, B
> will use the .dll X immediately
> 2)
> in case process A loaded a .dll X and exit, while process B already
> loaded another .dll(s) and collide with .dll X's VM address, .dll X
> will be rebased to other VM address, right?
> so, if process C then load .dll X again, and the address used by .dll
> X (rebased by B already) collides with the .dll(s) loaded by C, C will
> load another instances of .dll X and rebase it to the "free" virtual
> memory address.
> so there will be two instances of .dll X
>
> am I correct?



Not really. There's no need to have 2 copies of DLL. I better say .so
library, since I don't know for sure about DLL. The code would be stored
in the same physical memory. But different processes may access that
code at different virtual addresses. Things are "virtual". And this can be
used to map the same "virtual" address to different "physical" pages and
different "virtual" addresses to the same "physical" pages. The first
approach is used by 'fork', the second is used when loading shared
libraries.

Andrei
=?iso-8859-1?q?M=E5ns_Rullg=E5rd?=

2004-01-25, 9:34 pm

Andrei Voropaev <avorop@mail.ru> writes:
quote:

> Not really. There's no need to have 2 copies of DLL. I better say .so
> library, since I don't know for sure about DLL. The code would be stored
> in the same physical memory. But different processes may access that
> code at different virtual addresses.



This works only if the shared library uses position independent code.
If it doesn't, all memory references in the code will have to be
adjusted to point to the correct places. The library will have a
relocation table listing all instructions using absolute addresses
that need to be checked.

--
Måns Rullgård
mru@kth.se
=?iso-8859-1?q?M=E5ns_Rullg=E5rd?=

2004-01-25, 9:34 pm

mru@kth.se (Måns Rullgård) writes:
quote:

> Andrei Voropaev <avorop@mail.ru> writes:
>
>
> This works only if the shared library uses position independent code.
> If it doesn't, all memory references in the code will have to be
> adjusted to point to the correct places. The library will have a
> relocation table listing all instructions using absolute addresses
> that need to be checked.



Note, not all dynamic linkers support this.

--
Måns Rullgård
mru@kth.se
Erik de Castro Lopo

2004-01-26, 7:35 am

Baron wrote:
quote:

>
> Then I have a question on windows DLL loading...
> as I know there are something called "rebasing" where the desired
> virtual memory address of a .DLL (can be set when compile) is not
> available, the OS needs to do a 'rebasin' by changing all the memory
> references in the code to a new memory base...
>
> if different programs (in the case of fork, 2 processes can use the
> same virtual memory which may points to different physical memory) can
> goes into the same memory address, why loading a .dll needs
> rebasing???



Its usually not a code problem but a data problem. Code should
not be written to, so only one copy *should* be needed. However,
if the DLL accesses data, you will need a copy of this data for
each program that links to the DLL.

Unfortunately, because the code has pointers and addresses that
point to the data, the code then needs to be modified on a per
process basis to point to the different data segments which
therefore means that the code does need to be copied and modifed (rebasing).

This is a flaw of the microsoft OS. They insist on making their
DLL use position dependand code, while Linux uses sharded libraries
use position independant code. You might care to look these two
concepts up on the web somewhere.

Erik
--
+-----------------------------------------------------------+
Erik de Castro Lopo nospam@mega-nerd.com (Yes it's valid)
+-----------------------------------------------------------+
"Linux everywhere pretty much eliminates the need for Java everywhere"
-- Bruce Ide in letter to LWN editors
David Schwartz

2004-01-26, 10:34 am


"Erik de Castro Lopo" <nospam@mega-nerd.com> wrote in message
news:4015749A.65EFD8FE@mega-nerd.com...

quote:

> Unfortunately, because the code has pointers and addresses that
> point to the data, the code then needs to be modified on a per
> process basis to point to the different data segments which
> therefore means that the code does need to be copied and modifed
> (rebasing).
>
> This is a flaw of the microsoft OS. They insist on making their
> DLL use position dependand code, while Linux uses sharded libraries
> use position independant code. You might care to look these two
> concepts up on the web somewhere.




I don't think you know what you're talking about. Either that or using
terms like 'data segments' and 'position inddependant code' to mean
something totally different from what they nomally mean.

DS




Baron

2004-01-26, 12:35 pm

> This works only if the shared library uses position independent code.
quote:

> If it doesn't, all memory references in the code will have to be
> adjusted to point to the correct places. The library will have a
> relocation table listing all instructions using absolute addresses
> that need to be checked.



this is confusing
1) the relocation table is used at RUNTIME?
e.g. if process A loaded the .dll at memory location 0x1000,
while process B's 0x1000 is NOT available
do you mean there is relocation table for process B e.g. (0x3000 is
free for process B, but the .dll is loaded to 0x1000 by process A, so
when ever process B reference the dll, the relocation is simply map
0x3000 (VM address of the dll 'seen' by process B) -> 0x1000 (actual
VM address)
then the OS will map the Virtual Address of the dll to physical
address..
but that's another matter....

2)what does 'rebasing' actually change?
What i think is that it will change the memory reference (virtual
address of course) in the dll.
If you said that there is only 1 copy of the dll....
I don't know how exactly it works! As I think the 'rebasing' stuff
occurs at LOAD TIME
e.g.
Process A already loaded DLL X into memory 0x1000 and running a
function inside DLL X
now Process B tried to load DLL X, but the base address of DLL X is
NOT AVAILABLE for Process B.
so...what will happen?
I don't think the OS can MOVE DLL X from 0x1000 to other Virtual
Memory Location where Both Process A and B are 'free'

3) It seems to me that Position Independent Code would have
performance impact over that of Position Dependent Code, right???

Thank you very much!!!
David Schwartz

2004-01-26, 2:34 pm


"Baron" <baronng@astri.org> wrote in message
news:a9fc9c1a.0401261735.6ebd9172@posting.google.com...

quote:

> this is confusing
> 1) the relocation table is used at RUNTIME?



It's used at attach time, when the DLL is attached to by a process.

quote:

> e.g. if process A loaded the .dll at memory location 0x1000,
> while process B's 0x1000 is NOT available
> do you mean there is relocation table for process B e.g. (0x3000 is
> free for process B, but the .dll is loaded to 0x1000 by process A, so
> when ever process B reference the dll, the relocation is simply map
> 0x3000 (VM address of the dll 'seen' by process B) -> 0x1000 (actual
> VM address)
> then the OS will map the Virtual Address of the dll to physical
> address..
> but that's another matter....



No, process B could not care one bit about what virtual address process
A mapped the DLL. The problem would be if the DLL was coded to load at
virtual address 0x1000 and that address was already in use by a program that
tried to load the DLL.

quote:

> 2)what does 'rebasing' actually change?
> What i think is that it will change the memory reference (virtual
> address of course) in the dll.



Well, it doesn't change it in the DLL file itself. It changes it in the
DLL as seen by a particular process.

quote:

> If you said that there is only 1 copy of the dll....



Windows supports both shared and unshared segments in DLLs. If a program
modifies a byte in a shared segment, the DLL file itself is modified and all
processes using the DLL see that change. However, the segments that are
rebased are never shared, they're unshared. If a process modified a byte in
an unshared segment, then it stops sharing the page containing that byte
with other processes and gets its own private copy of that page.

quote:

> I don't know how exactly it works! As I think the 'rebasing' stuff
> occurs at LOAD TIME
> e.g.
> Process A already loaded DLL X into memory 0x1000 and running a
> function inside DLL X
> now Process B tried to load DLL X, but the base address of DLL X is
> NOT AVAILABLE for Process B.
> so...what will happen?



You're confused. Process A and process B have totally independent
virtual address space, so there is no way one process can use another
processes virtual address space. The virtual address would have to already
be in use in the process that's trying to attach to the DLL.

quote:

> I don't think the OS can MOVE DLL X from 0x1000 to other Virtual
> Memory Location where Both Process A and B are 'free'




One process' virtual address space has nothing to do with any other
process' virtual address space, so this doesn't make any sense.

quote:

> 3) It seems to me that Position Independent Code would have
> performance impact over that of Position Dependent Code, right???




Yes, PIC is generally slightly slower. However, the advantages of not
having to make a separate copy of a page for many processes just because one
byte needs to be relocated make PIC advantageous for any shared library code
that you expect to be frequently used by more than one process at a time. It
is, essentially, a size/speed tradeoff. PIC code can also be attached to
faster, though that rarely matters.

DS



Baron

2004-01-26, 3:34 pm

I think I am ok with .so, which use position independent code,
I can understand the situration where two processes access the same
..so in one physical location from two different virtual memory
locations
(I guess each process/.so has a table indicating the 'base-address' of
the .so)
so
if Process A's .so occupy 0x1000-0x2000
Process B's .so occupy 0x3000-0x4000
while the .so actually loaded to physical address 0x9000-0xA000
the 'base-address' index for .so in Process A would probably = 0x8000
and
the 'base-address' index for .so in Process B would probably = 0x6000
(so it adds more work in runtime for position independent code)

While for the case of position dependent code like Microsoft's .DLL
what would happen?!?!?
I can guess that the performance for MS .dll would be better than .so
but I guess two processes can't refer to the SAME .dll if there are
conflicts on their virtual memory addresses.
so in this case
would the .dll be COPIED and MODIFIED? coz the .dll has to be
'rebased' to different addresses for Process A and Process B.....

Thank you!
quote:

> I don't think you know what you're talking about. Either that or using
> terms like 'data segments' and 'position inddependant code' to mean
> something totally different from what they nomally mean.
>
> DS


Baron

2004-01-26, 6:34 pm

> No, process B could not care one bit about what virtual address process
quote:

> A mapped the DLL. The problem would be if the DLL was coded to load at
> virtual address 0x1000 and that address was already in use by a program that
> tried to load the DLL.


Yes but if the DLL is shared by both Process A and Process B, the
relation becomes
A---.DLL---B
since .DLL has to exist in both Process A and Process B's virtual
address (I assume .dll is sharable.....please correct me if I'm
wrong..)
so the .DLL has to find a virtual address that is free in the virtual
address space in both Process A and Process B, right?
quote:

> Well, it doesn't change it in the DLL file itself. It changes it in the
> DLL as seen by a particular process.


do you mean that there will be 2 dll?
e.g.
- Process A load the .DLL from FILE to MEMORY, and mark the pages used
by the .DLL copy-on-write
- Process B load .DLL again
- if Process B needs the .DLL to be REBASED => rebase occur on the
..DLL, but since the pages used by .DLL are COPY-ON-WRITE =>
essentially the .DLL is duplicated with new REBASED virtual address

right???
quote:

> Windows supports both shared and unshared segments in DLLs. If a program
> modifies a byte in a shared segment, the DLL file itself is modified and all
> processes using the DLL see that change. However, the segments that are
> rebased are never shared, they're unshared. If a process modified a byte in
> an unshared segment, then it stops sharing the page containing that byte
> with other processes and gets its own private copy of that page.


this backed up the explaination of having 2 instances of the dll when
rebase is needed for any process that loads that dll
quote:

> You're confused. Process A and process B have totally independent
> virtual address space, so there is no way one process can use another
> processes virtual address space. The virtual address would have to already
> be in use in the process that's trying to attach to the DLL.


I know process A and process B have 2 independent virtual address
space...
but I was thought that the .dll is shared by process A and B, and that
act as a linkage between 2 processes' virtual address space;
I'm wrong because the .dll isn't really shared by process A and B if
rebasing occur.
i.e. if a dll occupy the virtual address from 0x1000 to 0x2000
and Process A and Process B can load the dll to 0x1000-0x2000 without
rebasing
=> the dll is SHARED
HOWEVER, if any one of the process A or/and B needs to rebase the dll
(as 0x1000-0x2000 is occupied by other .dll/codes) a new copy of the
dll is created (due to copy-of-write -- write occur when rebasing)
right???
quote:

> Yes, PIC is generally slightly slower. However, the advantages of not
> having to make a separate copy of a page for many processes just because one
> byte needs to be relocated make PIC advantageous for any shared library code
> that you expect to be frequently used by more than one process at a time. It
> is, essentially, a size/speed tradeoff. PIC code can also be attached to
> faster, though that rarely matters.


what this means is that if rebase NEVER OCCUR, PIC won't be STRICTLY
slower than absolute addressing?
as I know, REBASING takes lots of time (esp for large dll).
so
- PIC consume less space because the library (.so) can be shared with
all processes (no rebasing, no copy-on-write)
- PIC is slower when rebasing is not needed
right???

thank you
=?iso-8859-1?q?M=E5ns_Rullg=E5rd?=

2004-01-26, 7:34 pm

"David Schwartz" <davids@webmaster.com> writes:
quote:

>
> Yes, PIC is generally slightly slower.



Only on braid dead machines like the Intel x86. The impact there is
caused be the severe shortage of registers, and PIC uses one of them
for special purposes. Real CPUs have so many registers that using one
specially isn't much of a problem.

--
Måns Rullgård
mru@kth.se
Michel Bardiaux

2004-01-27, 1:34 am

Baron wrote:
quote:

>
> So, all the VM space (e.g. 0 to 2^32 or 4G) are available for any process??



No, the amount of VM available to each process could be limited by
software limits in the OS, or by hardware limits such as a limited page
table.
quote:

> e.g. if I have 4G memory



of *physical* memory?
quote:

>, I have process A and process B
> process A use 0x0000 to 2G?
> process B can also use 0x0000 to 2G?



Yes.
quote:

> while the OS will map
> Process A: 0x0000 -> 2G to (physical) 0x0000 -> 2G
> Process B: 0x0000 -> 2G to (physical) 2G - > 4G
> ?



No, the virtual-to-physical mapping could be totally random.
[QUOTE][color=darkred]
>


--
Michel Bardiaux
Peaktime Belgium S.A. Bd. du Souverain, 191 B-1160 Bruxelles
Tel : +32 2 790.29.41

David Schwartz

2004-01-27, 8:35 am


"Baron" <baronng@astri.org> wrote in message
news:a9fc9c1a.0401262338.5f62dc9e@posting.google.com...

quote:


[QUOTE][color=darkred]
> Yes but if the DLL is shared by both Process A and Process B, the
> relation becomes
> A---.DLL---B
> since .DLL has to exist in both Process A and Process B's virtual
> address (I assume .dll is sharable.....please correct me if I'm
> wrong..)
> so the .DLL has to find a virtual address that is free in the virtual
> address space in both Process A and Process B, right?




No. There is no reason the DLL has to be mapped into the same virtual
address for both processes.

quote:

> do you mean that there will be 2 dll?
> e.g.
> - Process A load the .DLL from FILE to MEMORY, and mark the pages used
> by the .DLL copy-on-write
> - Process B load .DLL again
> - if Process B needs the .DLL to be REBASED => rebase occur on the
> .DLL, but since the pages used by .DLL are COPY-ON-WRITE =>
> essentially the .DLL is duplicated with new REBASED virtual address
>
> right???




No. The DLL is mapped into a particular process' virtual address space
through a mapping. That mapping can make changes, including mapping any
physical address to any virtual address in that process and including
substituting some pages mapped into process private pages rather than shared
pages that hold cached pages from the original file.

quote:

> this backed up the explaination of having 2 instances of the dll when
> rebase is needed for any process that loads that dll


quote:


[QUOTE][color=darkred]
> I know process A and process B have 2 independent virtual address
> space...
> but I was thought that the .dll is shared by process A and B, and that
> act as a linkage between 2 processes' virtual address space;



Right, through the physical page. In other words, process A might map
physical page 0x1000000 at virtual address space 0x1000 and process B might
map that same physical page at his virtual address space 0x2000.
Virtual-to-physical address translations are done through a mapping and each
process has its own mapping.

quote:

> I'm wrong because the .dll isn't really shared by process A and B if
> rebasing occur.



No, it really is. Just some pages become unshared because one process
modifies them. The sharing is read-only, so any attempt to modify a page
breaks the sharing and the process that attempted the modification gets a
private copy and its mapping is changed to map that virtual address to the
new private copy.

quote:

> i.e. if a dll occupy the virtual address from 0x1000 to 0x2000
> and Process A and Process B can load the dll to 0x1000-0x2000 without
> rebasing
> => the dll is SHARED
> HOWEVER, if any one of the process A or/and B needs to rebase the dll
> (as 0x1000-0x2000 is occupied by other .dll/codes) a new copy of the
> dll is created (due to copy-of-write -- write occur when rebasing)
> right???




No, the DLL is always shared just like all files always are.

quote:

> what this means is that if rebase NEVER OCCUR, PIC won't be STRICTLY
> slower than absolute addressing?
> as I know, REBASING takes lots of time (esp for large dll).
> so
> - PIC consume less space because the library (.so) can be shared with
> all processes (no rebasing, no copy-on-write)
> - PIC is slower when rebasing is not needed
> right???




Usually you don't particularly care about load time. Execution time is
more important. However, memory usage can be important as well, especially
for a shared object file that will be used by large numbers of processes.

PIC will, in general, run slightly slower. However, it is more shareable
and the number of pages that will become unshared when multiple processes
use the shared code is much lower for PIC.

DS



Baron

2004-01-27, 12:35 pm

> > e.g. if I have 4G memory
quote:

> of *physical* memory?


yes...of course...
Intel has PAE - allow 36 bits memory addressing..., right?
do intel implment it using special instruction
e.g.
change_page to page 01 (all the way to 16)
access memory normally
change_page to page 06 (all the way to 16)
access memory normally
,etc?

quote:

>
> No, the virtual-to-physical mapping could be totally random.


ar...that's ture....the physical memory can be pagefile on harddisk, right?
Baron

2004-01-27, 12:35 pm

> Only on braid dead machines like the Intel x86. The impact there is
quote:

> caused be the severe shortage of registers, and PIC uses one of them
> for special purposes. Real CPUs have so many registers that using one
> specially isn't much of a problem.



so the registers used is the 'base' address of the so in a particular
process, right?
so different process can load different 'base' address for the .so,
and each time the .so is accessed, the base address adds to the
position independent code (which actually use 'relative addressing',
right?

I'm pretty comfortable with the fork/dll concept now

what about shared memory object?
do the OS allocate it by searching a common available space for ALL
processes or
there is a special reserved virtual memory addresses that are solely
for storing shared memory object?

thanks!!!!
you guys are truely professional!
=?iso-8859-1?q?M=E5ns_Rullg=E5rd?=

2004-01-27, 12:35 pm

baronng@astri.org (Baron) writes:
quote:

> what about shared memory object? do the OS allocate it by searching
> a common available space for ALL processes or there is a special
> reserved virtual memory addresses that are solely for storing shared
> memory object?



Shared memory doesn't need to have the same virtual or physical
address. The programmer must take care not to place pointers in
shared memory, since they would probably be invalid in other processes
sharing the memory.

--
Måns Rullgård
mru@kth.se
David Schwartz

2004-01-27, 2:35 pm


"Baron" <baronng@astri.org> wrote in message
news:a9fc9c1a.0401271730.765b0341@posting.google.com...

quote:

> what about shared memory object?
> do the OS allocate it by searching a common available space for ALL
> processes or
> there is a special reserved virtual memory addresses that are solely
> for storing shared memory object?




There is no such thing as a "common available space for all processes".
Every process has its own virtual memory space. One process does not care
about another process' virtual memory space.

DS



Baron

2004-01-27, 3:34 pm

> No. There is no reason the DLL has to be mapped into the same virtual
quote:

> address for both processes.


but DLL, unlike .so, use ABSOLUTE (virtual) Addressing, so the DLL has
to be the SAME Virtual address for both processes IF both processes
share the SAME DLL

if the DLL mapped into the DIFFERENT virtual address - REBASING of the
DLL already occured -> one of the process already get the PRIVATE copy
of the DLL....
right?
quote:

> No. The DLL is mapped into a particular process' virtual address space
> through a mapping. That mapping can make changes, including mapping any
> physical address to any virtual address in that process and including
> substituting some pages mapped into process private pages rather than shared
> pages that hold cached pages from the original file.


I think DLL is loaded to the virtual address space DIRECTLY, but not
through any mapping.....otherwise, there is no need to REBASE a
DLL.....
virtual address -> physical address mapping seems to be another matter
my main focus is on the virtual address of DLL, where the DLL is
shared between two (or more) processes...
quote:

> Right, through the physical page. In other words, process A might map
> physical page 0x1000000 at virtual address space 0x1000 and process B might
> map that same physical page at his virtual address space 0x2000.
> Virtual-to-physical address translations are done through a mapping and each
> process has its own mapping.


Yes..I'm clear about this
but DLL/processes doesn't care about physical address
space....actually i think physical address space is hidden from any
processes - that's the principal of Virtual Memory, right??
quote:

> No, it really is. Just some pages become unshared because one process
> modifies them. The sharing is read-only, so any attempt to modify a page
> breaks the sharing and the process that attempted the modification gets a
> private copy and its mapping is changed to map that virtual address to the
> new private copy.


"some pages become unshared because one process modifies them"
exactly...what i mean if REBASING occur, I assume most pages got it's
own copy ...
what I tried to say is in case REBASING occur, the DLL is essentially
UNSHARED..
quote:

> No, the DLL is always shared just like all files always are.
> Usually you don't particularly care about load time. Execution time is
> more important. However, memory usage can be important as well, especially
> for a shared object file that will be used by large numbers of processes.
> PIC will, in general, run slightly slower. However, it is more shareable
> and the number of pages that will become unshared when multiple processes
> use the shared code is much lower for PIC.


that's because pages are 'copy-on-write' when rebasing the DLL, right?
while .so don't need any rebasing -> most of the code pages are
shared.

thx
Baron

2004-01-27, 5:34 pm

> There is no such thing as a "common available space for all processes".
quote:

> Every process has its own virtual memory space. One process does not care
> about another process' virtual memory space.



then, how do shared memory object allocated by the OS?
where do they exist?
do process A access a shared memory object using the virtual address
that is the used by by process B, who is also accessing the same
shared memory object?

thx
David Schwartz

2004-01-27, 6:34 pm


"Baron" <baronng@astri.org> wrote in message
news:a9fc9c1a.0401272022.ec37c8d@posting.google.com...

quote:


[QUOTE][color=darkred]
> but DLL, unlike .so, use ABSOLUTE (virtual) Addressing, so the DLL has
> to be the SAME Virtual address for both processes IF both processes
> share the SAME DLL



Nope. Files can be shared even if they're mapped at different addresses,
DLLs too.

quote:

> if the DLL mapped into the DIFFERENT virtual address - REBASING of the
> DLL already occured -> one of the process already get the PRIVATE copy
> of the DLL....
> right?




Nope. The DLL file itself is not rebased, only the file as seen by a
process is rebased. Some of the pages will therefore become private, but
that can happen many other ways, DLL rebasing is far from unique in this
respect.

quote:


[QUOTE][color=darkred]
> I think DLL is loaded to the virtual address space DIRECTLY, but not
> through any mapping.....otherwise, there is no need to REBASE a
> DLL.....
> virtual address -> physical address mapping seems to be another matter
> my main focus is on the virtual address of DLL, where the DLL is
> shared between two (or more) processes...




No, you're confused. The rebasing is needed if the DLL cannot be mapped
into a process' address space at the DLL's preferred address.

quote:


[QUOTE][color=darkred]
> Yes..I'm clear about this
> but DLL/processes doesn't care about physical address
> space....actually i think physical address space is hidden from any
> processes - that's the principal of Virtual Memory, right??




Right. So the DLL can physically exist at one particular physical
address and be mapped into different virtual addresses in different
processes. Mapping at different virtual addresses does not prohibit sharing.

quote:


[QUOTE][color=darkred]
> "some pages become unshared because one process modifies them"
> exactly...what i mean if REBASING occur, I assume most pages got it's
> own copy ...
> what I tried to say is in case REBASING occur, the DLL is essentially
> UNSHARED..




Your assumption is likely incorrect. In any event, it's a statistical
argument -- what percentage of the DLL's pages will have at least one
relocation entry.

quote:


[QUOTE][color=darkred]
> that's because pages are 'copy-on-write' when rebasing the DLL, right?



Yes.

quote:

> while .so don't need any rebasing -> most of the code pages are
> shared.




If a .so is compiled as PIC, it won't necessarily need rebasing.
However, .so's can be compiled with relocation entries, in which case they
will need the equivalent of rebasing. Even PIC can still wind up with
relocation entries or unsharing in other ways (such as self-modifying code).

DS




David Schwartz

2004-01-27, 6:34 pm


"Baron" <baronng@astri.org> wrote in message
news:a9fc9c1a.0401272233.5913146@posting.google.com...

quote:

[QUOTE][color=darkred]
> then, how do shared memory object allocated by the OS?



The OS allocates pages of physical memory.

quote:

> where do they exist?



In physical memory at some particular physical address.

quote:

> do process A access a shared memory object using the virtual address
> that is the used by by process B, who is also accessing the same
> shared memory object?




No, every process has its own virtual address space. So process A cannot
use a virtual address space used by process B. It has to have its own
mapping of the physical into its own virtual address space.

To put it another way, there is no difference to the kernel whether two
processes map a shared memory segment into the same virtual address or
different ones. There in different virtual address tables entirely (because
each process has one), so there already as different as they can get as far
as the kernel is concerned.

Think of a process' virtual address space as a street and virtual
addresses as street addresses. 19 Smith Street and 19 Jones Street are no
more similar than 19 Smith Street and 23 Jones Street.

DS




Michel Bardiaux

2004-01-28, 3:38 am

Baron wrote:
quote:

>
> yes...of course...
> Intel has PAE - allow 36 bits memory addressing..., right?
> do intel implment it using special instruction
> e.g.
> change_page to page 01 (all the way to 16)
> access memory normally
> change_page to page 06 (all the way to 16)
> access memory normally
> ,etc?



You're not making any sense.
quote:

>
>
>
>
> ar...that's ture....the physical memory can be pagefile on harddisk, right?



No. Physical memory is RAM. The hard disk enters the dance only when the
OS decides to copy a page to disk before unmapping it. Where the page
goes on the disk is NOT stored in the hardware page table. What happens
is that some virtual pages are mapped to some physical pages, but some
other virtual pages can be mapped to NOTHING. Then a page fault occurs
when the process attempts to access the page.


--
Michel Bardiaux
Peaktime Belgium S.A. Bd. du Souverain, 191 B-1160 Bruxelles
Tel : +32 2 790.29.41

Jerry Feldman

2004-01-28, 1:35 pm

On 27 Jan 2004 22:33:00 -0800
baronng@astri.org (Baron) wrote:
quote:

>
> then, how do shared memory object allocated by the OS?
> where do they exist?
> do process A access a shared memory object using the virtual address
> that is the used by by process B, who is also accessing the same
> shared memory object?


Note that Linux and various Unixes can do this a bit differently. When a
process initially loads, its virtual addresses are mapped based on
system defaults and how the code was set up by the programmer, compiler,
linker and loader. The process may also load libraries using dlopen(2)
and allocate memory pages with mmap(2). The system then will map a
shared memory object into an appropriate address space. For instance,
HP-UX allocates 4 regions indexed by space registers. One of these
regions is intended for shared objects. Again, processes may have the
same shared object mapped at different addresses. Other Unixes map
shared objects into different regions based on OS specific defaults.

Lets say process A and B uses libc.so, libx.so and liby.so, but based on
the way they were linked, A might map libc, libx and liby in that order
where B might map libc, liby and libx in that order.

I use the term "map" since that is what is done.

Additionally, two processes might share an mmaped region, but thay also
can be at different virtual addresses.

In Linux and Unix it really does not matter.

WRT: fork(2). In general the parent and child of a fork with have
identical virtual addresses at the point of the fork since they are
effectively identical twins. But, after the fork, dynamically loaded
shared object can be loaded at different virtual addresses.
--
Jerry Feldman <gaf-nospam-at-blu.org>
Boston Linux and Unix user group
http://www.blu.org PGP key id:C5061EA9
PGP Key fingerprint:053C 73EC 3AC1 5C44 3E14 9245 FB00 3ED5 C506 1EA9
Brian Raiter

2004-01-28, 1:35 pm

>> Yes, PIC is generally slightly slower.
quote:

>
> Only on braid dead machines like the Intel x86.



But such machines are nearly useless anyway, since they're so
susceptible to dredlocks.

b
Baron

2004-01-28, 7:34 pm

> > Only on braid dead machines like the Intel x86.
quote:

>
> But such machines are nearly useless anyway, since they're so
> susceptible to dredlocks.
>


you mean Intel x86 machines are useless?
I think their performance is superb.
Baron

2004-01-28, 7:34 pm

> Note that Linux and various Unixes can do this a bit differently. When a
quote:

> process initially loads, its virtual addresses are mapped based on
> system defaults and how the code was set up by the programmer, compiler,
> linker and loader. The process may also load libraries using dlopen(2)
> and allocate memory pages with mmap(2). The system then will map a
> shared memory object into an appropriate address space. For instance,
> HP-UX allocates 4 regions indexed by space registers. One of these
> regions is intended for shared objects. Again, processes may have the
> same shared object mapped at different addresses. Other Unixes map
> shared objects into different regions based on OS specific defaults.


I think this is true for Windows / other OS as well.
shared memory object are just memory location where several processes
map part of their (virtual) memory space to the same physical memory
location => 'shared memory';
virtual memory <=> physical memory mapping are independent from the
process's view, right?
processes only 'see' virtual memory.
quote:

> Lets say process A and B uses libc.so, libx.so and liby.so, but based on
> the way they were linked, A might map libc, libx and liby in that order
> where B might map libc, liby and libx in that order.


this still holds for windows, right?
but it may affect which lib will do the 'rebasing'
quote:

> WRT: fork(2). In general the parent and child of a fork with have
> identical virtual addresses at the point of the fork since they are
> effectively identical twins. But, after the fork, dynamically loaded
> shared object can be loaded at different virtual addresses.



so the parent and child is actually two different processes which
shares nothing except the 'physical pages'; but since process don't
'see' physical pages
we can actually treat them as two different processes which totally
unrelated to each others...the copy-on-write stuff is for the
performance issue
=?iso-8859-1?q?M=E5ns_Rullg=E5rd?=

2004-01-28, 8:34 pm

baronng@astri.org (Baron) writes:
quote:

> you mean Intel x86 machines are useless?
> I think their performance is superb.



Have you ever used an Alpha or Power4? Compared to these the x86 is a
silly joke.

--
Måns Rullgård
mru@kth.se
David Schwartz

2004-01-28, 9:35 pm


"Baron" <baronng@astri.org> wrote in message
news:a9fc9c1a.0401290030.6c3adaf3@posting.google.com...

quote:

> shared memory object are just memory location where several processes
> map part of their (virtual) memory space to the same physical memory
> location => 'shared memory';
> virtual memory <=> physical memory mapping are independent from the
> process's view, right?
> processes only 'see' virtual memory.




Correct.

quote:

> this still holds for windows, right?
> but it may affect which lib will do the 'rebasing'




Corrcet.

quote:

>
> so the parent and child is actually two different processes which
> shares nothing except the 'physical pages'; but since process don't
> 'see' physical pages
> we can actually treat them as two different processes which totally
> unrelated to each others...the copy-on-write stuff is for the
> performance issue



Correct.

Now you're getting it.

DS




Sean Burke

2004-01-29, 8:35 am


baronng@astri.org (Baron) writes:
quote:

> you mean Intel x86 machines are useless?
> I think their performance is superb.



I think you missed a wordplay on "braid" and "dredlocks".

-SEan
Baron

2004-01-29, 12:34 pm

> Have you ever used an Alpha or Power4? Compared to these the x86 is a
quote:

> silly joke.



They're not in the market anymore, right?

I've learnt that RISC machine is better than CISC's one
and VLIW machine (Itanium) is even better than RISC
but it turns out that Intel x86 or the 64-bit version (Opteron) is /
will be a sucessful product

Opteron is a CISC x86 machine, right?
it has more registers and cache
and P4 Prescott can have 32 pipline stages

I remember that RISC machine can have more registers/cache/clock speed
(pipline stages)/etc.
but it's seems that today's P4/Opteron can also achieve it.
Baron

2004-01-29, 12:34 pm

> Correct.
quote:

>
> Now you're getting it.
>
> DS




Yeah, thank you very much.
I'm really much more clear now!

Thanks everyone!
=?iso-8859-1?q?M=E5ns_Rullg=E5rd?=

2004-01-29, 8:34 pm

baronng@astri.org (Baron) writes:
quote:

>
> They're not in the market anymore, right?



Alpha is being phased out. Power4 is very much in the market, just
like the upcoming Power5 will be. The PPC970 used in Apple's G5
Powermac is based on the Power4.
quote:

> I've learnt that RISC machine is better than CISC's one
> and VLIW machine (Itanium) is even better than RISC



You'll have to define "better" before that makes any sense.
quote:

> but it turns out that Intel x86 or the 64-bit version (Opteron) is /
> will be a sucessful product
>
> Opteron is a CISC x86 machine, right?
> it has more registers and cache
> and P4 Prescott can have 32 pipline stages



There's nothing good about having many pipeline stages. On the
contrary, many pipeline stages are bad for performance when there is a
missed branch prediction.
quote:

> I remember that RISC machine can have more registers/cache/clock speed
> (pipline stages)/etc.
> but it's seems that today's P4/Opteron can also achieve it.



Intel optimize their CPUs for clock speed only. The simple reason
behind that is that idiots shopping for a new PC will see the
fantastic numbers like 3 GHz and think it must be fast. Real CPUs are
optimized for actual use, or at least for benchmarks.

--
Måns Rullgård
mru@kth.se
Baron

2004-01-30, 1:36 am

> Alpha is being phased out. Power4 is very much in the market, just
quote:

> like the upcoming Power5 will be. The PPC970 used in Apple's G5
> Powermac is based on the Power4.


but G5 isn't as good as it claimed...
quote:

>
>
> You'll have to define "better" before that makes any sense.


performance

quote:

>
>
> There's nothing good about having many pipeline stages. On the
> contrary, many pipeline stages are bad for performance when there is a
> missed branch prediction.


i know that.
but isn't that for RISC machine; it can run higher clock speed as each
instruction takes short time?
quote:

>
>
> Intel optimize their CPUs for clock speed only. The simple reason
> behind that is that idiots shopping for a new PC will see the
> fantastic numbers like 3 GHz and think it must be fast. Real CPUs are
> optimized for actual use, or at least for benchmarks.


that's true
I like AMD more then Intel.
AMD has better architecture, esp for the hypertransport / 64bit x86
=?iso-8859-1?q?M=E5ns_Rullg=E5rd?=

2004-01-30, 2:36 am

baronng@astri.org (Baron) writes:
quote:

> but G5 isn't as good as it claimed...



Numbers?
quote:

> performance



It still comes down to the individual implementation. A good CISC can
be far better than a bad RISC.
quote:

> i know that.
> but isn't that for RISC machine; it can run higher clock speed as each
> instruction takes short time?
>
> that's true
> I like AMD more then Intel.
> AMD has better architecture, esp for the hypertransport / 64bit x86



Why do you think they stopped printing the actual clock speed? Now,
if they'd only drop the x86 compatibility it could make somewhat
decent machine. The fact is that all modern pentium3, pentium4,
athlon etc. CPUs are made as a RISC core with an ugly x86 translator
tacked on. Imagine what could be done if that silicon were put to
better use.

--
Måns Rullgård
mru@kth.se
Baron

2004-01-31, 3:34 am

mru@kth.se (Måns Rullgård) wrote in message news:<yw1xwu79fo98.fsf@kth.se>...
quote:

> baronng@astri.org (Baron) writes:
>
>
> Numbers?



apple pick a 'bad' compiler for intel/amd
http://news.com.com/2100-1042_3-1020631.html

From this (int result)
http://spl.haxial.net/apple-powermac-G5/
G5 - 800
P4 3G - 1152
AMD 3200+ - 1044
there are also other tests

at least, RISC computer still can't out perform a CISC machine.
quote:

>
>
> It still comes down to the individual implementation. A good CISC can
> be far better than a bad RISC.


it seems so....you can see many of the hollywood films are swtiching
from mac to intel + linux.....let alone those expensive SGI
machines...
quote:

>
>
> Why do you think they stopped printing the actual clock speed? Now,
> if they'd only drop the x86 compatibility it could make somewhat
> decent machine. The fact is that all modern pentium3, pentium4,
> athlon etc. CPUs are made as a RISC core with an ugly x86 translator
> tacked on. Imagine what could be done if that silicon were put to
> better use.


I don't think they use RISC like transmeta(spelling??)
intel / amd cpu can truely execute 2(to 4) instructions / clock
Sponsored Links






Free braindumps | Software forum | Database administration forum

Copyright 2003 - 2008 webservertalk.com