Re: how to detect thread switches

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

 



On Wed, Aug 18, 2010 at 00:16, Ashwath <itsmeash@xxxxxxxxx> wrote:
> Hi All,
>
> I am writing a profiler for an embedded application running on linux and I
> need to detect thread context switches.
> Threading is done using pThread library

Since I am not sure the way Linux works on your embedded platform,
perhaps you need to find it out first: is your platform use N:1 thread
approach? 1:1? Or M:N (very unlikely,  but who knows?)

Assuming 1:1, like our current NPTL does in normal (non embedded ) IBM
PC x86  compatible, thread switch is basically a schedule() too. Thus,
put a hook in schedule in kernel space, that should do it.

If N:1, then it must be the master thread that does the switch. Try to
strace your application (the master thread) and try to figure out the
time this thread does something can be indicated as "switching". Quite
likely it is done using ptrace.

Then, you might need to hook ptrace ( harder) or find a function that
call it and hook it there (perhaps easier).

-- 
regards,

Mulyadi Santosa
Freelance Linux trainer and consultant

blog: the-hydra.blogspot.com
training: mulyaditraining.blogspot.com

--
To unsubscribe from this list: send an email with
"unsubscribe kernelnewbies" to ecartis@xxxxxxxxxxxx
Please read the FAQ at 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