public inbox for ecos-discuss@sourceware.org
 help / color / mirror / Atom feed
* [ECOS] CPU usage by threads
@ 2002-10-24  0:11 Daniel Lidsten
  2002-10-24  1:07 ` Andrew Lunn
  0 siblings, 1 reply; 4+ messages in thread
From: Daniel Lidsten @ 2002-10-24  0:11 UTC (permalink / raw)
  To: Ecos-Discuss

Hi,

I would like to know how much CPU time each thread in the system make
use of but i currently don't see any easy way of doing this? Does it
exists any such feature? If not, maybe it is possible to add some hook
functions that gets called by the kernel each time it performs a task
switch. These functions can then perform some logging, or just do
nothing at all if they are not used.

Regards, Daniel Lidsten

--
Before posting, please read the FAQ: http://sources.redhat.com/fom/ecos
and search the list archive: http://sources.redhat.com/ml/ecos-discuss

^ permalink raw reply	[flat|nested] 4+ messages in thread

* Re: [ECOS] CPU usage by threads
  2002-10-24  0:11 [ECOS] CPU usage by threads Daniel Lidsten
@ 2002-10-24  1:07 ` Andrew Lunn
  0 siblings, 0 replies; 4+ messages in thread
From: Andrew Lunn @ 2002-10-24  1:07 UTC (permalink / raw)
  To: Daniel Lidsten; +Cc: Ecos-Discuss

On Thu, Oct 24, 2002 at 09:11:10AM +0200, Daniel Lidsten wrote:
> Hi,
> 
> I would like to know how much CPU time each thread in the system make
> use of but i currently don't see any easy way of doing this? Does it
> exists any such feature? If not, maybe it is possible to add some hook
> functions that gets called by the kernel each time it performs a task
> switch. These functions can then perform some logging, or just do
> nothing at all if they are not used.
> 
> Regards, Daniel Lidsten

It is possible, but needs a bit of work on your side. You need to turn
on instrumentation and configure it correctly. It will then log a
instrumentation event every time a thread switch occurs. The event has
a time stamp. From this you can work out how long each thread ran
for. ISR and DSR time will be counted inside which every thread was
running at the time. If you need to exclude that, it may be possible,
but again its more work.

Using instrumentation is in the documentation. You will also find a
little tool i wrote for decoding the binary data to something a little
easier to read by humans in packages/kernel/current/host/instr

       Andrew

-- 
Before posting, please read the FAQ: http://sources.redhat.com/fom/ecos
and search the list archive: http://sources.redhat.com/ml/ecos-discuss

^ permalink raw reply	[flat|nested] 4+ messages in thread

* Re: [ECOS] CPU usage by threads
  2002-11-05  8:02 Daniel Lidsten
@ 2002-11-05  8:35 ` NavEcos
  0 siblings, 0 replies; 4+ messages in thread
From: NavEcos @ 2002-11-05  8:35 UTC (permalink / raw)
  To: Daniel Lidsten; +Cc: Ecos-Discuss

Yes, you just need one interrupt to do this.  This is OUTSIDE of any thread 
context.

When the interrupt fires, call CygThread::self () to determine which thread 
was running when the interrupt fired.  You'll need an array of structures 
that is something like this:

struct ThreadCounts
{
  CygThread *pThreadId; //Thisis what CygThread::self() will return
  u32 u32Count;
};

to keep track of the counts of each thread.

This is statistical sampling.  You're assuming that the more often you see a 
particular thread when the interrupt occurs, the more often that particular 
thread runs.  This is true 99.9% of the time.

In a SIDE NOTE, which most likely will NOT affect you, you may have what's 
called the "Thundering Herd" problem.  This is when your interrupt that you 
use to sample which thread is running coincides with when a thread starts 
running.  I have never seen an embedded system that is affected by this much 
since in most embedded systems it's interrupts that drive the system.  This 
problem WILL happen in systems like Unix, Windows, and other systems that do 
a lot of scheduling based off the clock though.  Again - this is just a side 
note and I mention it so you can research it if you feel like it.

-Rich

On Tuesday 05 November 2002 04:02 pm, Daniel Lidsten wrote:
> Hi again,
>
> I dont get exactly how you mean in the below text. Do you mean that i
> shall create a periodic alarm inside each thread and let it write the
> thread ID into an array or something and then have some other thread
> reading it and presenting it?
>
> Or can i use just ONE interrupt that do all this? If so then i need to
> know that the interrupt is run within the disrupted threads' context and
> not some special interrupt thread.
>
> I would approtiate it very much it you could clearify this for me.
>
> Regards, Daniel
>
> > Anyhow, if you just want to do cpu usage by task, I'd
> > recommend making a
> > periodic interrupt and then calling CygThread::self () to
> > figure out which
> > thread was running at the time, and just keep counts per
> > thread and do
> > division.  This will impact your system VERY little.  Have a
> > low priority
> > thread periodically print the values and you can get a pretty
> > good idea of
> > where you spend most of your time.   For best results, you
> > want an interrupt
> > with a system tick that cannot be divided into the system
> > tick.  I've heard
> > that one of the best profilers uses a 97 Hz clock with a
> > system clock of 100
> > Hz (eCos' default and most Unix's too).
> >
> > Our tool profiles the code, so it's probably overkill.  It
> > tells you where you
> > spend most of your time, what task you were in and the call
> > stack as well.
> >
> > Later,
> > -Rich
> >
> > > Regards, Daniel
> > >
> > > > -----Original Message-----
> > > > From: NavEcos [mailto:ecos@navosha.com]
> > > > Sent: den 24 oktober 2002 23:11
> > > > To: Daniel Lidsten
> > > > Subject: Re: [ECOS] CPU usage by threads
> > > >
> > > > On Thursday 24 October 2002 04:29 am, you wrote:
> > > > > Hi,
> > > > >
> > > > > I just took a peek at your site regarding the profiling
> > > >
> > > > tool it looks
> > > >
> > > > > very intresting. Do you have it for windows platform? How
> > > >
> > > > much does it
> > > >
> > > > > cost? Do you have any more information about it - some manual?
> > > >
> > > > Well, we're just tooling up.  That individual tool (don't have a
> > > > heart attack) is like $5K, but that's for a site license, as many
> > > > developers as you want
> > > > can use it for your project.  We are a small company, we
> >
> > need $.  You
> >
> > > > wouldn't be able to develop such a tool as cheaply.
> > > >
> > > > We're also bringing up a memory profiler as well, that
> >
> > will help you
> >
> > > > eliminate memory leaks.
> > > >
> > > > We have two other tools under development as well but they are
> > > > several weeks away from completion to no real point in mentioning
> > > > them yet.
> > > >
> > > > -Rich
> > > >
> > > > > Regards, Daniel Lidsten
> > > > >
> > > > > > -----Original Message-----
> > > > > > From: NavEcos [mailto:ecos@navosha.com]
> > > > > > Sent: den 24 oktober 2002 10:35
> > > > > > To: Daniel Lidsten
> > > > > > Subject: Re: [ECOS] CPU usage by threads
> > > > > >
> > > > > > On Thursday 24 October 2002 12:11 am, Daniel Lidsten wrote:
> > > > > > > Hi,
> > > > > > >
> > > > > > > I would like to know how much CPU time each thread in the
> > > > > >
> > > > > > system make
> > > > > >
> > > > > > > use of but i currently don't see any easy way of doing
> > > > > >
> > > > > > this? Does it
> > > > > >
> > > > > > > exists any such feature? If not, maybe it is possible to
> > > > > >
> > > > > > add some hook
> > > > > >
> > > > > > > functions that gets called by the kernel each time it
> > > > > >
> > > > > > performs a task
> > > > > >
> > > > > > > switch. These functions can then perform some logging,
> > > >
> > > > or just do
> > > >
> > > > > > > nothing at all if they are not used.
> > > > > > >
> > > > > > > Regards, Daniel Lidsten
> > > > > >
> > > > > > We provide a tool that will do this:
> > > > >
> > > > > http://ecos.dynu.com/~ecos3/prof.html
> > > > >
> > > > > But it's commercial.
> > > > >
> > > > > -Rich


--
Before posting, please read the FAQ: http://sources.redhat.com/fom/ecos
and search the list archive: http://sources.redhat.com/ml/ecos-discuss

^ permalink raw reply	[flat|nested] 4+ messages in thread

* RE: [ECOS] CPU usage by threads
@ 2002-11-05  8:02 Daniel Lidsten
  2002-11-05  8:35 ` NavEcos
  0 siblings, 1 reply; 4+ messages in thread
From: Daniel Lidsten @ 2002-11-05  8:02 UTC (permalink / raw)
  To: ecos; +Cc: Ecos-Discuss

Hi again,

I dont get exactly how you mean in the below text. Do you mean that i
shall create a periodic alarm inside each thread and let it write the
thread ID into an array or something and then have some other thread
reading it and presenting it?

Or can i use just ONE interrupt that do all this? If so then i need to
know that the interrupt is run within the disrupted threads' context and
not some special interrupt thread.

I would approtiate it very much it you could clearify this for me.

Regards, Daniel

> Anyhow, if you just want to do cpu usage by task, I'd 
> recommend making a 
> periodic interrupt and then calling CygThread::self () to 
> figure out which 
> thread was running at the time, and just keep counts per 
> thread and do 
> division.  This will impact your system VERY little.  Have a 
> low priority 
> thread periodically print the values and you can get a pretty 
> good idea of 
> where you spend most of your time.   For best results, you 
> want an interrupt 
> with a system tick that cannot be divided into the system 
> tick.  I've heard 
> that one of the best profilers uses a 97 Hz clock with a 
> system clock of 100 
> Hz (eCos' default and most Unix's too).
> 
> Our tool profiles the code, so it's probably overkill.  It 
> tells you where you 
> spend most of your time, what task you were in and the call 
> stack as well.
> 
> Later,
> -Rich
> 
> > Regards, Daniel
> >
> > > -----Original Message-----
> > > From: NavEcos [mailto:ecos@navosha.com]
> > > Sent: den 24 oktober 2002 23:11
> > > To: Daniel Lidsten
> > > Subject: Re: [ECOS] CPU usage by threads
> > >
> > > On Thursday 24 October 2002 04:29 am, you wrote:
> > > > Hi,
> > > >
> > > > I just took a peek at your site regarding the profiling
> > >
> > > tool it looks
> > >
> > > > very intresting. Do you have it for windows platform? How
> > >
> > > much does it
> > >
> > > > cost? Do you have any more information about it - some manual?
> > >
> > > Well, we're just tooling up.  That individual tool (don't have a 
> > > heart attack) is like $5K, but that's for a site license, as many
> > > developers as you want
> > > can use it for your project.  We are a small company, we 
> need $.  You
> > > wouldn't be able to develop such a tool as cheaply.
> > >
> > > We're also bringing up a memory profiler as well, that 
> will help you 
> > > eliminate memory leaks.
> > >
> > > We have two other tools under development as well but they are 
> > > several weeks away from completion to no real point in mentioning 
> > > them yet.
> > >
> > > -Rich
> > >
> > > > Regards, Daniel Lidsten
> > > >
> > > > > -----Original Message-----
> > > > > From: NavEcos [mailto:ecos@navosha.com]
> > > > > Sent: den 24 oktober 2002 10:35
> > > > > To: Daniel Lidsten
> > > > > Subject: Re: [ECOS] CPU usage by threads
> > > > >
> > > > > On Thursday 24 October 2002 12:11 am, Daniel Lidsten wrote:
> > > > > > Hi,
> > > > > >
> > > > > > I would like to know how much CPU time each thread in the
> > > > >
> > > > > system make
> > > > >
> > > > > > use of but i currently don't see any easy way of doing
> > > > >
> > > > > this? Does it
> > > > >
> > > > > > exists any such feature? If not, maybe it is possible to
> > > > >
> > > > > add some hook
> > > > >
> > > > > > functions that gets called by the kernel each time it
> > > > >
> > > > > performs a task
> > > > >
> > > > > > switch. These functions can then perform some logging,
> > >
> > > or just do
> > >
> > > > > > nothing at all if they are not used.
> > > > > >
> > > > > > Regards, Daniel Lidsten
> > > > >
> > > > > We provide a tool that will do this:
> > > >
> > > > http://ecos.dynu.com/~ecos3/prof.html
> > > >
> > > > But it's commercial.
> > > >
> > > > -Rich
> 
> 

--
Before posting, please read the FAQ: http://sources.redhat.com/fom/ecos
and search the list archive: http://sources.redhat.com/ml/ecos-discuss

^ permalink raw reply	[flat|nested] 4+ messages in thread

end of thread, other threads:[~2002-11-05 16:35 UTC | newest]

Thread overview: 4+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2002-10-24  0:11 [ECOS] CPU usage by threads Daniel Lidsten
2002-10-24  1:07 ` Andrew Lunn
2002-11-05  8:02 Daniel Lidsten
2002-11-05  8:35 ` NavEcos

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for read-only IMAP folder(s) and NNTP newsgroup(s).