Calculating processor usage (M68K)

Do you have a question? Post it now! No Registration Necessary

Translate This Thread From English to

Threaded View
Could someone tell me know how to calculate MIPS being used by an
existing application, on an existing processor?

I'm not looking for raw processor power available (so benchmark pgms
won't do). We have an application (real-time, infinte loop) running on
the processor, and want to know how busy the processor is on an
average. It would suffice even if we could only determine the
worst-case utilization. The application runs on pSOS on M68K.

Thanks,
Test

Re: Calculating processor usage (M68K)

Quoted text here. Click to load it

Do you mean a polling loop that is looking for activitity or are
the activitites interrupt driven?

If you are trying to decide whether you can utilize a faster
processor, are there other things you need to measure, such as
latency?

Quoted text here. Click to load it


Re: Calculating processor usage (M68K)

Quoted text here. Click to load it

I assume that you have development capability on the existing
application and are not trying to anaylze a "black box".  The
distinction between doing effective work and spinning in an idle loop
is one that can only be made by knowing the application code itself.
You will need to find where the processor is when it is "idle".  Then,
make a temporary modification to the code to leave some evidence of
the time that is spent in idle.  That can be either hardware or
software.  In software, you might sample a high-speed clock on entry
and exit from the idle code and accumulate the time spent in some
counters that are eventually reported out.  In hardware, you might set
a digital output to indicate idle vs. non-idle, then monitor that bit
with a scope and estimate the duty-cycle, or low-pass filter it and
measure the average voltage with a voltmeter.


-Robert Scott
 Ypsilanti, Michigan
(Reply through newsgroups, not by direct e-mail, as automatic reply address is
fake.)


Re: Calculating processor usage (M68K)
Quoted text here. Click to load it

How about a 'working' flag and two counters?
- When in the idle loop, set the flag to 'idle'
- When entering any activity, set the flag to 'at work'
- Use a timer interrupt at some arbitrary interval.
- In the ISR do something like:
void TimerIsr(void)
{
    if(working) atwork++;
    else idling++;
}

This should give you a reasonable indication what percentage of time is
spent.

Rob



Re: Calculating processor usage (M68K)
Quoted text here. Click to load it

And how do you know that you are back at work (without modifying the
scheduler) ?

---
42Bastian
Do not email to snipped-for-privacy@yahoo.com, it's a spam-only account :-)
We've slightly trimmed the long signature. Click to see the full one.
Re: Calculating processor usage (M68K)
Quoted text here. Click to load it

This works well in a monolithic state-engine design. It doesn't work when a
scheduler preemptively interrupts tasks, as the scheduling is (should be)
transparent to the tasks.

Rob



Re: Calculating processor usage (M68K)
Quoted text here. Click to load it

It depends a lot on whether tasks are suspended when idle/waiting for I/O
or just busy-looping in their slice until interrupted.

I'm wire-wrapping a "junkbox wars" hobby project.  If I have 3 I/O lines
left over, I'm planning to drive 8 LEDs on the front panel.  When the
switcher swaps tasks, it'll turn on that task's (or class of tasks') LED.
One LED reserved for the idle loop.  I'm planning to use cooperative
multitasking, but it should also work pre-emptive.  The overhead is a few
cycles per context-switch.

An empirical indicator of limited use except for the fun of watching one
LED flare and the others dim as one task grabs the CPU...

--
Ron Sharp.




Re: Calculating processor usage (M68K)
Quoted text here. Click to load it


pSOS gives you a hook that gets called whenever there's a task switch.
If you have access to a good real-time clock, this can give you
lots of information about idle time.

--
    mac the naf

Re: Calculating processor usage (M68K)
The following article describes two techniques for measuring
processor utilization:

http://www.eventhelix.com/RealtimeMantra/CongestionControl/congestion_control_triggers.htm

Sandeep
--
http://www.EventHelix.com/EventStudio
EventStudio 2.0 - System Architecture Design CASE Tool

Re: Calculating processor usage (M68K)

Quoted text here. Click to load it


You may write a timer interrupt (period depends on how accurated your
figures must be) and check which is the return address i.e. the
interrupted function.
Then count numbers of interrupts and number of times where you did
interrupt the idle loop (or a self written low-prio task).

---
42Bastian
Do not email to snipped-for-privacy@yahoo.com, it's a spam-only account :-)
We've slightly trimmed the long signature. Click to see the full one.
Re: Calculating processor usage (M68K)
snipped-for-privacy@yahoo.com (42Bastian Schick) wrote in message
Quoted text here. Click to load it
This works well if you have a spare timer that can be programmed to
issue a non-maskable (level 7 on 68k) interrupt. You can use a buffer
to capture the value of  the program counter and use the data to
analyse the systems steady-state behaviour (if it has one!).

I have also used the abort button for this purpose but it made my
finger
tired.
Quoted text here. Click to load it

Re: Calculating processor usage (M68K)
Quoted text here. Click to load it
 
Which frequency did you achieve ?

(Sorry, could not resist :-)
---
42Bastian
Do not email to snipped-for-privacy@yahoo.com, it's a spam-only account :-)
We've slightly trimmed the long signature. Click to see the full one.
Re: Calculating processor usage (M68K)
Quoted text here. Click to load it

In the past I have used spare bits on a parallel port to monitor each task.
By putting a line of code at the beginning & end of each task to set its
corresponding I/O bit as below, you can monitor the absolute service times
as well as the % utilisation of the CPU by that task with a CRO.

taskN(normal param list)
{
    *IOPort |= (1<<N);                    // Set bit N, where N is the port
bit no.
    ...
    ...    // normal code for task
    ...
    *IOPort &= ~(1<<N);                // Clear bit N
}                                                     // Normal exit (must
handle other 'returns' too.)

Once the number of pins under observation exceeds the number of Y channels
on your CRO, to view total loading you can use one pin exclusively as a sync
pulse, preferably in the most reliably stable (minimum jitter) code (usually
in a HW interrupt handler).

All other tasks can use the same pin N, giving a good total % CPU
indication, albeit without identification of the task.  If you then put the
bit set/clr code in each task in turn, you can identify them again.

If the port bits are on a Duart, which has separate but unreadable regs for
setting & clearing port bits, the two lines become:

*(Duart+SetReg) = (1<<N)        // Set bit N
*(Duart+ClrReg) = (1<<N)         // And clear it with same mask

Good luck.
Jim Adamthwaite.



Site Timeline