hi all<br><br> in the kernel modules,we often use the macro __init.<br>if we only discuss the __init for functions.__init tells the <br>compiler to put the function in a special section.and the <br>function are used once.So the code of this function should<br>
be freed from the memory after the first call.<br><br>so i write a sample module:<br><br>#include <linux/module.h><br>#include <linux/init.h><br><br>void __init print_k(void)<br>{<br> int k = 9;<br> printk("<0>k = %d\n",k);<br>
}<br><br>static int __init hello_init(void)<br>{<br> printk("<0>hello kernel!\n");<br> print_k();<br> print_k();<br> return 0;<br>}<br><br>static void __exit hello_exit(void)<br>{<br> printk("<0>bye kernel!\n");<br>
}<br><br>module_init(hello_init);<br>module_exit(hello_exit);<br>MODULE_LICENSE("GPL");<br><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>Thanks in advance!<br>wanny<br>