[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
Re: question about exit and task memory
On Wed, 10 Jan 2001, Santosh Eraniose wrote:
> Hello,
> In the exit code in Linux,
>
> lock_kernel();
> fake_volatile:
> #ifdef CONFIG_BSD_PROCESS_ACCT
> acct_process(code);
> #endif
> sem_exit();
> __exit_mm(tsk);
> __exit_files(tsk);
> __exit_fs(tsk);
> __exit_sighand(tsk);
> exit_thread();
> tsk->state = TASK_ZOMBIE;
> tsk->exit_code = code;
> exit_notify();
> put_exec_domain(tsk->exec_domain);
> if (tsk->binfmt && tsk->binfmt->module)
> __MOD_DEC_USE_COUNT(tsk->binfmt->module);
> schedule();
>
>
> He does exit_mm(tsk) and then proceesds to perform other actions as seen above.
> If the associated memory of the tsk is freed, how is the tsk able to
Ya, associated memory is freed, but current is not freed, ie
kfree(current) or similar call is not there, so data structure related to
current is still there in kernel memory.
In fact exit_notify() has call to notify_parent() about the status
of exit. And if the child is fortunate enough so that parent waits for it,
in sys_wait4(), it calls release(p) in which free_task_struct(p) is
called. For an orphand, child_reaper is always there.
> continue after exit_mm?
>
> If its another task who is the releasing , it is understandable, but here
> the active task deallocates his associated memory
> as in the beginning he does
> struct task_struct *tsk = current;
>
> Is he running in a different context when he calls exit?
Ya, do_exit calls schedule() and never returns.( see man exit).
> Thanks
> --
> Santosh Eraniose
> -----------------------------------------------
> Member Technical
> Sony Software Architecture Lab
> Bangalore
> --
> PGP Key available on request
> -----------------------------------------------
> -
> Kernelnewbies: Help each other learn about the Linux kernel.
> Archive: http://mail.nl.linux.org/
> IRC Channel: irc.openprojects.net / #kernelnewbies
> Web Page: http://www.surriel.com/kernelnewbies.shtml
>
--
sourav
-
Kernelnewbies: Help each other learn about the Linux kernel.
Archive: http://mail.nl.linux.org/
IRC Channel: irc.openprojects.net / #kernelnewbies
Web Page: http://www.surriel.com/kernelnewbies.shtml