繁体   English   中英

调用系统调用fork()时使用哪些函数

[英]What functions are used when the system call fork() is called

我一直在网上搜索以发现fork.c内使用了哪些功能以及以什么顺序使用,但是我似乎找不到答案。 我所看到的只是fork.c的作用。 我知道fork.c使用_do_fork(),但是我不知道它如何到达那里。

进行fork()系统调用时,它会通过复制调用过程来创建一个新过程。 新的过程将称为过程。

查看此代码的基本概述。

fork()->sys_fork()->do_fork()

sys_fork()
{
 1. First it will validate the arguments.
 2. Invoke do_fork.
 3. return pid. (child pid)
}

do_fork()
{
1. First it will Allocate new address space.
2. Copy Segments of Caller address space to new address space.
3. allocate new task_struct instance. (PCB)
4. copy caller task_struct entries to new task_struct.
5. return.
}

成功后,将在父级中返回子进程的PID,在子级中返回0。

注意:它们是另外几个调用,但是这两个是最重要的,如果您想了解更多信息,请查看内核源代码。 如果仍然需要帮助,请告诉我。

暂无
暂无

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM