由买买提看人间百态

boards

本页内容为未名空间相应帖子的节选和存档,一周内的贴子最多显示50字,超过一周显示500字 访问原贴
Unix版 - how to fork a subroutine in unix?
相关主题
fork() and execve() in Unix各位大哥帮忙,EXECVE()的使用
"fork" program question.[转载] waitpid 一问
multithread questionA question about thread of unix
Chinese platform in Unix?A problem about child process.
Is it possible to use COM technique on UNIX platform?请求帮助!!!
[转载] 请教:UNIX下process之间的signal问题FreeBSD: Can't kill child process!
unix 面试题,求答案 (转载)A Unix question
公司的opening - system SQA (转载)how to record the process end time in a child process and obtain it in the parent process?
相关话题的讨论汇总
话题: fork话题: vfork话题: subroutine话题: unix话题: parent
进入Unix版参与讨论
1 (共1页)
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

1 (共1页)
进入Unix版参与讨论
相关主题
how to record the process end time in a child process and obtain it in the parent process?Is it possible to use COM technique on UNIX platform?
Re: how to close port/socket from parent process?help!!!!!!!!![转载] 请教:UNIX下process之间的signal问题
关于nohup的问题unix 面试题,求答案 (转载)
unix 进程求救公司的opening - system SQA (转载)
fork() and execve() in Unix各位大哥帮忙,EXECVE()的使用
"fork" program question.[转载] waitpid 一问
multithread questionA question about thread of unix
Chinese platform in Unix?A problem about child process.
相关话题的讨论汇总
话题: fork话题: vfork话题: subroutine话题: unix话题: parent