Re: Linux Kernel and Device Drivers

2013-07-17 Thread Satya Prakash Prasad
Thanks to Srinivas and others. I got a point to start from.

Regards,
Prakash


On Thu, Jul 18, 2013 at 12:01 PM, Srinivas Ganji <
srinivasganji.ker...@gmail.com> wrote:

> 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.
>
> #include 
> #include 
> #include 
>
> MODULE_LICENSE("Dual BSD/GPL");
>
> static int hello_init(void)
> {
> struct task_struct *task;
>
> printk("Hello World!\n");
>  for_each_process(task) {
>  printk("%s %d\n", task->comm, task->pid);
> }
>  printk("\n\n\n");
>  for(task = &init_task; ((task=next_task(task)) != &init_task) ; )
>  printk("%s %d\n", task->comm, task->pid);
>  printk("\n\n\n");
>  return 0;
> }
>
> static void hello_exit(void)
> {
> printk("Good bye!\n");
> }
>
> module_init(hello_init);
> module_exit(hello_exit);
>
> By the way, you can do as suggested by Valdis, too. I do search for a
> particular code/strings using find, xargs, grep combination.
>
> I hope this helps you.
>
> Regards,
> Srinivas
>
>
>
> On Tue, Jul 16, 2013 at 12:42 PM, Satya Prakash Prasad <
> unixkernel...@gmail.com> wrote:
>
>> Thanks .. I have another question. I was trying to practice some kernel
>> process management APIs as in
>> http://reiber.org/nxt/pub/Linux/LinuxKernelDevelopment/Linux.Kernel.Development.3rd.Edition.pdf(Linux
>>  Kernel Development by Robert Love, 3rd edition).
>>
>> 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 'struct task_struct' to find it parent's process
>> identifier, how many tasks are in which state, creating kernel threads etc?
>>
>> Any idea?
>>
>>
>> On Mon, Jul 15, 2013 at 2:32 PM, Srinivas Ganji <
>> srinivasganji.ker...@gmail.com> wrote:
>>
>>> As per as I know, you can follow two text books.
>>>
>>> 1. Linux Kernel Development by Robert Love, 3rd edition.
>>> 2. Linux Device Drivers by Alessandro Rubini, Jonathan Corbet, Greh
>>> Kroah-Hartman. 3rd edition.
>>>
>>> At the same time, you can practice the exercises given in the text books
>>> - practice makes a man perfect. The other thing is "Make your hands dirty
>>> by digging the kernel code whenever you have a doubt".
>>>
>>> Regards,
>>> Srinivas
>>>
>>>
>>>
>>>
>>> On Mon, Jul 15, 2013 at 2:06 PM, Satya Prakash Prasad <
>>> unixkernel...@gmail.com> wrote:
>>>
 Please let me know how to study and get hands on experience on Linux
 Kernel and Device Drivers?

 Regards,
 Prakash

 ___
 Kernelnewbies mailing list
 Kernelnewbies@kernelnewbies.org
 http://lists.kernelnewbies.org/mailman/listinfo/kernelnewbies


>>>
>>
>
___
Kernelnewbies mailing list
Kernelnewbies@kernelnewbies.org
http://lists.kernelnewbies.org/mailman/listinfo/kernelnewbies


Re: Linux Kernel and Device Drivers

2013-07-17 Thread Srinivas Ganji
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.

#include 
#include 
#include 

MODULE_LICENSE("Dual BSD/GPL");

static int hello_init(void)
{
struct task_struct *task;

printk("Hello World!\n");
 for_each_process(task) {
printk("%s %d\n", task->comm, task->pid);
}
 printk("\n\n\n");
 for(task = &init_task; ((task=next_task(task)) != &init_task) ; )
printk("%s %d\n", task->comm, task->pid);
 printk("\n\n\n");
 return 0;
}

static void hello_exit(void)
{
printk("Good bye!\n");
}

module_init(hello_init);
module_exit(hello_exit);

By the way, you can do as suggested by Valdis, too. I do search for a
particular code/strings using find, xargs, grep combination.

I hope this helps you.

Regards,
Srinivas



On Tue, Jul 16, 2013 at 12:42 PM, Satya Prakash Prasad <
unixkernel...@gmail.com> wrote:

> Thanks .. I have another question. I was trying to practice some kernel
> process management APIs as in
> http://reiber.org/nxt/pub/Linux/LinuxKernelDevelopment/Linux.Kernel.Development.3rd.Edition.pdf(Linux
>  Kernel Development by Robert Love, 3rd edition).
>
> 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 'struct task_struct' to find it parent's process
> identifier, how many tasks are in which state, creating kernel threads etc?
>
> Any idea?
>
>
> On Mon, Jul 15, 2013 at 2:32 PM, Srinivas Ganji <
> srinivasganji.ker...@gmail.com> wrote:
>
>> As per as I know, you can follow two text books.
>>
>> 1. Linux Kernel Development by Robert Love, 3rd edition.
>> 2. Linux Device Drivers by Alessandro Rubini, Jonathan Corbet, Greh
>> Kroah-Hartman. 3rd edition.
>>
>> At the same time, you can practice the exercises given in the text books
>> - practice makes a man perfect. The other thing is "Make your hands dirty
>> by digging the kernel code whenever you have a doubt".
>>
>> Regards,
>> Srinivas
>>
>>
>>
>>
>> On Mon, Jul 15, 2013 at 2:06 PM, Satya Prakash Prasad <
>> unixkernel...@gmail.com> wrote:
>>
>>> Please let me know how to study and get hands on experience on Linux
>>> Kernel and Device Drivers?
>>>
>>> Regards,
>>> Prakash
>>>
>>> ___
>>> Kernelnewbies mailing list
>>> Kernelnewbies@kernelnewbies.org
>>> http://lists.kernelnewbies.org/mailman/listinfo/kernelnewbies
>>>
>>>
>>
>
___
Kernelnewbies mailing list
Kernelnewbies@kernelnewbies.org
http://lists.kernelnewbies.org/mailman/listinfo/kernelnewbies


Re: Linux Kernel and Device Drivers

2013-07-16 Thread Valdis . Kletnieks
On Tue, 16 Jul 2013 12:42:37 +0530, Satya Prakash Prasad said:
> 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 'struct task_struct' to find it parent's process
> identifier, how many tasks are in which state, creating kernel threads etc?

cd /usr/src/linux
find include -type f | xargs grep 'struct task_struct' | more

Lots of hits.  One of those is the definition of the structure. Study it
and learn from that.  The rest are where other things refer to the
structure - much can be learned from studying what *else* refers to it
and why.

Enjoy.


pgpMTfezbx5QD.pgp
Description: PGP signature
___
Kernelnewbies mailing list
Kernelnewbies@kernelnewbies.org
http://lists.kernelnewbies.org/mailman/listinfo/kernelnewbies


Re: Linux Kernel and Device Drivers

2013-07-16 Thread Satya Prakash Prasad
Thanks .. I have another question. I was trying to practice some kernel
process management APIs as in
http://reiber.org/nxt/pub/Linux/LinuxKernelDevelopment/Linux.Kernel.Development.3rd.Edition.pdf(Linux
Kernel Development by Robert Love, 3rd edition).

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 'struct task_struct' to find it parent's process
identifier, how many tasks are in which state, creating kernel threads etc?

Any idea?


On Mon, Jul 15, 2013 at 2:32 PM, Srinivas Ganji <
srinivasganji.ker...@gmail.com> wrote:

> As per as I know, you can follow two text books.
>
> 1. Linux Kernel Development by Robert Love, 3rd edition.
> 2. Linux Device Drivers by Alessandro Rubini, Jonathan Corbet, Greh
> Kroah-Hartman. 3rd edition.
>
> At the same time, you can practice the exercises given in the text books -
> practice makes a man perfect. The other thing is "Make your hands dirty by
> digging the kernel code whenever you have a doubt".
>
> Regards,
> Srinivas
>
>
>
>
> On Mon, Jul 15, 2013 at 2:06 PM, Satya Prakash Prasad <
> unixkernel...@gmail.com> wrote:
>
>> Please let me know how to study and get hands on experience on Linux
>> Kernel and Device Drivers?
>>
>> Regards,
>> Prakash
>>
>> ___
>> Kernelnewbies mailing list
>> Kernelnewbies@kernelnewbies.org
>> http://lists.kernelnewbies.org/mailman/listinfo/kernelnewbies
>>
>>
>
___
Kernelnewbies mailing list
Kernelnewbies@kernelnewbies.org
http://lists.kernelnewbies.org/mailman/listinfo/kernelnewbies


Re: Linux Kernel and Device Drivers

2013-07-15 Thread Srinivas Ganji
As per as I know, you can follow two text books.

1. Linux Kernel Development by Robert Love, 3rd edition.
2. Linux Device Drivers by Alessandro Rubini, Jonathan Corbet, Greh
Kroah-Hartman. 3rd edition.

At the same time, you can practice the exercises given in the text books -
practice makes a man perfect. The other thing is "Make your hands dirty by
digging the kernel code whenever you have a doubt".

Regards,
Srinivas




On Mon, Jul 15, 2013 at 2:06 PM, Satya Prakash Prasad <
unixkernel...@gmail.com> wrote:

> Please let me know how to study and get hands on experience on Linux
> Kernel and Device Drivers?
>
> Regards,
> Prakash
>
> ___
> Kernelnewbies mailing list
> Kernelnewbies@kernelnewbies.org
> http://lists.kernelnewbies.org/mailman/listinfo/kernelnewbies
>
>
___
Kernelnewbies mailing list
Kernelnewbies@kernelnewbies.org
http://lists.kernelnewbies.org/mailman/listinfo/kernelnewbies