开发者

Invocation of release_task() function?

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开发者_如何学Go explicitly, how is release_task() function invoked and the process descriptor of the child process deallocated?


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)


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.

0

上一篇:

下一篇:

精彩评论

暂无评论...
验证码 换一张
取 消

最新问答

问答排行榜