Re: newbie kernl module question

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

 



Hi..

>
> Are there any module code samples available where I could get how to
> interact with the task_struct in a module?

First you need to get the target's task_struct. One of the ways is using 
find_task_by_pid(). it receives the target PID of the process. You just 
need to include linux/sched.h header to use it

> How do I perform operations like finding how much memory a certain
> task is using? How much CPU it is using?

if you mean the current memory resident set size, then check 
task_struct->mm->rss.

CPU accounting... hm, try task_struct->per_cpu_utime (user time) and 
per_cpu_stime (system time). 

NB: I only check them according to my 2.4.x codes.

regards,

Mulyadi


> I would really appreciate any replies
>
> Regards
> Irfan
>
> --
> Kernelnewbies: Help each other learn about the Linux kernel.
> Archive:       http://mail.nl.linux.org/kernelnewbies/
> FAQ:           http://kernelnewbies.org/faq/


--
Kernelnewbies: Help each other learn about the Linux kernel.
Archive:       http://mail.nl.linux.org/kernelnewbies/
FAQ:           http://kernelnewbies.org/faq/


[Index of Archives]     [Newbies FAQ]     [Linux Kernel Mentors]     [Linux Kernel Development]     [IETF Annouce]     [Git]     [Networking]     [Security]     [Bugtraq]     [Yosemite]     [MIPS Linux]     [ARM Linux]     [Linux RAID]     [Linux SCSI]     [Linux ACPI]
  Powered by Linux