调用release_task()函数?
在Linux内核
中,进程终止后,通过调用release_task()
函数从系统中删除进程的进程描述符
。
我相信,当子进程终止时,父进程对子进程发出的 wait()
系统调用会调用 release_task()
函数。
假设父进程没有显式发出wait()
系统调用,那么如何调用release_task()
函数并释放子进程的进程描述符呢?
In Linux kernel
, the process descriptor
of a process is removed from the system by invoking the release_task()
function, after the process has terminated.
I believe, the wait()
system call issued by the parent process on the child process invokes the release_task()
function when the child process terminates.
Suppose the parent process does not issue a wait()
system call explicitly, how is release_task()
function invoked and the process descriptor of the child process deallocated?
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(2)
如果父进程不为子进程
wait(2)
,则子进程将成为僵尸
。只要父母还活着,孩子就不能被收割。当父母去世时,他所有未等待的孩子都会被init
收养。init
的工作之一是定期等待子进程(从而释放相关资源)If the parent process does not
wait(2)
for a child process, the child becomes azombie
. As long as the parent lives, the child cannot be reaped. When the parent dies, all his un-waited children are adopted byinit
. One of the jobs ofinit
is to periodically wait for children (thereby freeing associated resources)release_task( ) 函数将最后的数据结构与僵尸进程的描述符分离;它以两种可能的方式应用于僵尸进程:如果父进程对接收来自子进程的信号不感兴趣,则通过 do_exit( ) 函数,或者通过 wait4( ) > 或 waitpid( ) 系统在信号发送到父进程后调用。在后一种情况下,该函数还将回收进程描述符使用的内存,而在前一种情况下,内存回收将由调度程序完成,因为 do_exit() 调用 schedule ( )在最后一步。
更多信息,您可以参考《Understanding The Linux Kernel:I/O Ports And Process Management》一书。
The release_task( ) function detaches the last data structures from the descriptor of a zombie process; it is applied on a zombie process in two possible ways: by the do_exit( ) function if the parent is not interested in receiving signals from the child, or by the wait4( ) or waitpid( ) system calls after a signal has been sent to the parent. In the latter case, the function also will reclaim the memory used by the process descriptor, while in the former case the memory reclaiming will be done by the scheduler because the do_exit() calls schedule () in its last step.
For more information,you can refer to the book - Understanding The Linux Kernel:I/O Ports And Process Management.