<div dir="ltr"><div>Thanks to Srinivas and others. I got a point to start from.<br><br></div>Regards,<br>Prakash<br></div><div class="gmail_extra"><br><br><div class="gmail_quote">On Thu, Jul 18, 2013 at 12:01 PM, Srinivas Ganji <span dir="ltr">&lt;<a href="mailto:srinivasganji.kernel@gmail.com" target="_blank">srinivasganji.kernel@gmail.com</a>&gt;</span> wrote:<br>
<blockquote class="gmail_quote" style="margin:0 0 0 .8ex;border-left:1px #ccc solid;padding-left:1ex"><div dir="ltr">Yes. As said by Anish, I generally practice through a dummy hello world module. Suppose, if I want to print all the processes currently running, I do like this.<div>
<br><div><div>#include &lt;linux/module.h&gt;</div>
<div>#include &lt;linux/kernel.h&gt;</div><div>#include &lt;linux/sched.h&gt;</div><div><br></div><div>MODULE_LICENSE(&quot;Dual BSD/GPL&quot;);</div><div><br></div><div>static int hello_init(void)</div><div>{</div><div>
<span style="white-space:pre-wrap">        </span>struct task_struct *task; </div>
<div><br></div><div><span style="white-space:pre-wrap">        </span>printk(&quot;Hello World!\n&quot;);</div><div><span style="white-space:pre-wrap">        </span></div><div><span style="white-space:pre-wrap">        </span>for_each_process(task) {</div>

<div><span style="white-space:pre-wrap">                </span>printk(&quot;%s %d\n&quot;, task-&gt;comm, task-&gt;pid);</div><div><span style="white-space:pre-wrap">        </span>}</div><div><span style="white-space:pre-wrap">        </span></div>

<div><span style="white-space:pre-wrap">        </span>printk(&quot;\n\n\n&quot;);</div><div><span style="white-space:pre-wrap">        </span></div><div><span style="white-space:pre-wrap">        </span>for(task = &amp;init_task; ((task=next_task(task)) != &amp;init_task) ; )</div>

<div><span style="white-space:pre-wrap">                </span>printk(&quot;%s %d\n&quot;, task-&gt;comm, task-&gt;pid);</div><div><span style="white-space:pre-wrap">        </span></div><div><span style="white-space:pre-wrap">        </span>printk(&quot;\n\n\n&quot;);</div>

<div><span style="white-space:pre-wrap">        </span></div><div><span style="white-space:pre-wrap">        </span>return 0;<br></div><div>}</div><div><br></div><div>static void hello_exit(void)</div><div>{</div><div><span style="white-space:pre-wrap">        </span>printk(&quot;Good bye!\n&quot;);</div>

<div>}</div><div><br></div><div>module_init(hello_init);</div><div>module_exit(hello_exit);</div></div><div><br></div></div><div>By the way, you can do as suggested by Valdis, too. I do search for a particular code/strings using find, xargs, grep combination.</div>

<div><br></div><div>I hope this helps you.</div><div><br></div><div>Regards,</div><div>Srinivas</div><div><br></div></div><div class="HOEnZb"><div class="h5"><div class="gmail_extra"><br><br><div class="gmail_quote">On Tue, Jul 16, 2013 at 12:42 PM, Satya Prakash Prasad <span dir="ltr">&lt;<a href="mailto:unixkernel497@gmail.com" target="_blank">unixkernel497@gmail.com</a>&gt;</span> wrote:<br>

<blockquote class="gmail_quote" style="margin:0 0 0 .8ex;border-left:1px #ccc solid;padding-left:1ex"><div dir="ltr"><span>Thanks .. I have another question. I was trying to practice some kernel process management APIs as in                       
                        <a href="http://www.linkedin.com/redirect?url=http%3A%2F%2Freiber%2Eorg%2Fnxt%2Fpub%2FLinux%2FLinuxKernelDevelopment%2FLinux%2EKernel%2EDevelopment%2E3rd%2EEdition%2Epdf&amp;urlhash=3MN8&amp;_t=tracking_disc" target="_blank">http://reiber.org/nxt/pub/Linux/LinuxKernelDevelopment/Linux.Kernel.Development.3rd.Edition.pdf</a>
                      
 (Linux Kernel Development by Robert Love, 3rd edition). 
<br>

<br>
I am not sure how to practice the code snippet given in the text book. I
 can understand the theory but do not find a way to practice. For 
example: I want to read a process &#39;struct task_struct&#39; to find it 
parent&#39;s process identifier, how many tasks are in which state, creating
 kernel threads etc?
<br>

<br>
Any idea?                      
                    </span></div><div><div><div class="gmail_extra"><br><br><div class="gmail_quote">On Mon, Jul 15, 2013 at 2:32 PM, Srinivas Ganji <span dir="ltr">&lt;<a href="mailto:srinivasganji.kernel@gmail.com" target="_blank">srinivasganji.kernel@gmail.com</a>&gt;</span> wrote:<br>


<blockquote class="gmail_quote" style="margin:0 0 0 .8ex;border-left:1px #ccc solid;padding-left:1ex"><div dir="ltr"><div>As per as I know, you can follow two text books. <br></div><div><br></div><div>1. Linux Kernel Development by Robert Love, 3rd edition. </div>


<div>2. Linux Device Drivers by Alessandro Rubini, Jonathan Corbet, Greh Kroah-Hartman. 3rd edition.</div>
<div><br></div><div>At the same time, you can practice the exercises given in the text books - practice makes a man perfect. The other thing is &quot;Make your hands dirty by digging the kernel code whenever you have a doubt&quot;.</div>



<div><br></div><div>Regards,</div><div>Srinivas</div><div><br></div><div><br></div></div><div class="gmail_extra"><br><br><div class="gmail_quote"><div><div>On Mon, Jul 15, 2013 at 2:06 PM, Satya Prakash Prasad <span dir="ltr">&lt;<a href="mailto:unixkernel497@gmail.com" target="_blank">unixkernel497@gmail.com</a>&gt;</span> wrote:<br>



</div></div><blockquote class="gmail_quote" style="margin:0 0 0 .8ex;border-left:1px #ccc solid;padding-left:1ex"><div><div><div dir="ltr"><div>Please let me know how to study and get hands on experience on Linux Kernel and Device Drivers?<br>



<br></div>Regards,<br>Prakash<br></div>
<br></div></div>_______________________________________________<br>
Kernelnewbies mailing list<br>
<a href="mailto:Kernelnewbies@kernelnewbies.org" target="_blank">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></blockquote></div><br></div>
</blockquote></div><br></div>
</div></div></blockquote></div><br></div>
</div></div></blockquote></div><br></div>