调用release_task()函数?

发布于 2024-11-14 06:46:06 字数 281 浏览 6 评论 0原文

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 技术交流群。

扫码二维码加入Web技术交流群

发布评论

需要 登录 才能够评论, 你可以免费 注册 一个本站的账号。

评论(2

木緿 2024-11-21 06:46:06

如果父进程不为子进程wait(2),则子进程将成为僵尸。只要父母还活着,孩子就不能被收割。当父母去世时,他所有未等待的孩子都会被 init 收养。 init 的工作之一是定期等待子进程(从而释放相关资源)

If the parent process does not wait(2) for a child process, the child becomes a zombie. As long as the parent lives, the child cannot be reaped. When the parent dies, all his un-waited children are adopted by init. One of the jobs of init is to periodically wait for children (thereby freeing associated resources)

゛时过境迁 2024-11-21 06:46:06

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.

~没有更多了~
我们使用 Cookies 和其他技术来定制您的体验包括您的登录状态等。通过阅读我们的 隐私政策 了解更多相关信息。 单击 接受 或继续使用网站,即表示您同意使用 Cookies 和您的相关数据。
原文