<span style="color:rgb(34,34,34);font-family:arial,sans-serif;font-size:13px;background-color:rgb(255,255,255)">Hi Vijay,</span><div style="color:rgb(34,34,34);font-family:arial,sans-serif;font-size:13px;background-color:rgb(255,255,255)">
<br></div><div style="color:rgb(34,34,34);font-family:arial,sans-serif;font-size:13px;background-color:rgb(255,255,255)">Is this a loadable kernel module or a built-in module?</div><div style="color:rgb(34,34,34);font-family:arial,sans-serif;font-size:13px;background-color:rgb(255,255,255)">
If it is a loadable module, everything still remains in the memory without being freed.</div><div style="color:rgb(34,34,34);font-family:arial,sans-serif;font-size:13px;background-color:rgb(255,255,255)"><br></div><div style="color:rgb(34,34,34);font-family:arial,sans-serif;font-size:13px;background-color:rgb(255,255,255)">
Functions and data defined with __init gets freed after their execution only if these are part of built-in kernel modules.</div><div style="color:rgb(34,34,34);font-family:arial,sans-serif;font-size:13px;background-color:rgb(255,255,255)">
<br></div><div style="color:rgb(34,34,34);font-family:arial,sans-serif;font-size:13px;background-color:rgb(255,255,255)">In your case, if the module is a loadable one, you can still access the print_k() from hello_exit() as its still residing in memory.</div>
<div style="color:rgb(34,34,34);font-family:arial,sans-serif;font-size:13px;background-color:rgb(255,255,255)"><br></div><div style="color:rgb(34,34,34);font-family:arial,sans-serif;font-size:13px;background-color:rgb(255,255,255)">
Regards,</div><div style="color:rgb(34,34,34);font-family:arial,sans-serif;font-size:13px;background-color:rgb(255,255,255)">-Amar</div><br><div class="gmail_quote">On Thu, Aug 16, 2012 at 5:23 PM, Vijay Chauhan <span dir="ltr"><<a href="mailto:kernel.vijay@gmail.com" target="_blank">kernel.vijay@gmail.com</a>></span> wrote:<br>
<blockquote class="gmail_quote" style="margin:0 0 0 .8ex;border-left:1px #ccc solid;padding-left:1ex">Hi,<br>
<div class="im"><br>
On Tue, Aug 14, 2012 at 9:34 AM, Mulyadi Santosa<br>
<<a href="mailto:mulyadi.santosa@gmail.com">mulyadi.santosa@gmail.com</a>> wrote:<br>
> Hi.. :)<br>
><br>
> On Tue, Aug 14, 2012 at 9:14 AM, 王哲 <<a href="mailto:wangzhe5004@gmail.com">wangzhe5004@gmail.com</a>> wrote:<br>
>> i use the __init for function print_k.<br>
>> in my opinion after the fisrt invoking the print_k in the hello_init.<br>
>> the memory of print_k will be freed,and the second invoking will<br>
>> not be executed.but the result of second invoking is executing .<br>
>><br>
>> why?<br>
><br>
> because you're still in module_init.... :)<br>
><br>
> right after modul init stage is done, _init marked function is thrown away...<br>
<br>
<br>
</div>Even if we call print_k() function inside hello_exit, it still works.<br>
At that point __init hello_init execution is over. How its still<br>
working?<br>
<br>
<br>
Regards,<br>
Vijay<br>
<div class="HOEnZb"><div class="h5"><br>
><br>
> --<br>
> regards,<br>
><br>
> Mulyadi Santosa<br>
> Freelance Linux trainer and consultant<br>
><br>
> blog: <a href="http://the-hydra.blogspot.com" target="_blank">the-hydra.blogspot.com</a><br>
> training: <a href="http://mulyaditraining.blogspot.com" target="_blank">mulyaditraining.blogspot.com</a><br>
><br>
> _______________________________________________<br>
> Kernelnewbies mailing list<br>
> <a href="mailto:Kernelnewbies@kernelnewbies.org">Kernelnewbies@kernelnewbies.org</a><br>
> <a href="http://lists.kernelnewbies.org/mailman/listinfo/kernelnewbies" target="_blank">http://lists.kernelnewbies.org/mailman/listinfo/kernelnewbies</a><br>
<br>
_______________________________________________<br>
Kernelnewbies mailing list<br>
<a href="mailto:Kernelnewbies@kernelnewbies.org">Kernelnewbies@kernelnewbies.org</a><br>
<a href="http://lists.kernelnewbies.org/mailman/listinfo/kernelnewbies" target="_blank">http://lists.kernelnewbies.org/mailman/listinfo/kernelnewbies</a><br>
</div></div></blockquote></div><br>