z*h 发帖数: 22 | 1 hi, guys,
I just wonder how I could fork a subroutine in unix other than the whole
copy of current process. any idea? thanks. | L********e 发帖数: 783 | 2 just use fork() API. And you need to include "unistd.h"
【在 z*h 的大作中提到】 : hi, guys, : I just wonder how I could fork a subroutine in unix other than the whole : copy of current process. any idea? thanks.
| j***y 发帖数: 87 | 3 I think in the current systems, all the fork functions will work as vforks.
it means that the system won't copy the whole context until it's necessary.
【在 z*h 的大作中提到】 : hi, guys, : I just wonder how I could fork a subroutine in unix other than the whole : copy of current process. any idea? thanks.
| L********e 发帖数: 783 | 4 fork is different from vfork as after vfork the child process shares the
same address space as the calling process. Because of the shared address,
you must be careful to use vfork.
【在 j***y 的大作中提到】 : I think in the current systems, all the fork functions will work as vforks. : it means that the system won't copy the whole context until it's necessary.
| m*****e 发帖数: 4193 | 5 You are definitely wrong.
【在 L********e 的大作中提到】 : fork is different from vfork as after vfork the child process shares the : same address space as the calling process. Because of the shared address, : you must be careful to use vfork.
| j***y 发帖数: 87 | 6 You are right that vfork does have some differences with fork. But I think
the difference between vork and the modern fork is that with vfork, you
yourself have to do a copy-on-write synchronization. But with fork, the system
will do it automatically.
In vfork, it does share address space with parent, but more exactly, it
borrows address space from parent. Because the parent will suspend as vfork
is called. But this is not consistant in all platforms, in some platforms,
after vfork, the parent w
【在 L********e 的大作中提到】 : fork is different from vfork as after vfork the child process shares the : same address space as the calling process. Because of the shared address, : you must be careful to use vfork.
| L********e 发帖数: 783 | 7 oh? where?
I hardly use vfork and i have no refernce book with
me right now.
【在 m*****e 的大作中提到】 : You are definitely wrong.
| L********e 发帖数: 783 | 8 //nod nod
you are right. In some platforms, the parent will be suspended after vfork.
why not just use fork to avoid any possible problems neh.
【在 j***y 的大作中提到】 : You are right that vfork does have some differences with fork. But I think : the difference between vork and the modern fork is that with vfork, you : yourself have to do a copy-on-write synchronization. But with fork, the system : will do it automatically. : In vfork, it does share address space with parent, but more exactly, it : borrows address space from parent. Because the parent will suspend as vfork : is called. But this is not consistant in all platforms, in some platforms, : after vfork, the parent w
|
|