To LUGNET HomepageTo LUGNET News HomepageTo LUGNET Guide Homepage
 Help on Searching
 
Post new message to lugnet.roboticsOpen lugnet.robotics in your NNTP NewsreaderTo LUGNET News Traffic PageSign In (Members)
 Robotics / 3619
3618  |  3620
Subject: 
CPU Time Required for RCX Instructions
Newsgroups: 
lugnet.robotics
Date: 
Wed, 10 Feb 1999 03:29:03 GMT
Viewed: 
1146 times
  
Someone recently asked how long it took to execute an RCX instruction. My
measurements show there is there is 1.75 msec of processing involved between
calls to the "RCX instruction loop" which then spends about 0.20 msec per
active task executing one opcode. More details follow.

Knowledge from pervious posts is that the RCX periodically executes
the "RCX instruction loop".  The "RCX instruction loop" then checks each of
the ten possible tasks in turn and if ready to run executes one instruction.
[I may not have this quite right -- someone correct me if I'm wrong]. Hence
one to 10 instructions can be executed dependent on the number of active
tasks.

I measured the following:
1.75 msec (milli-seconds) of "outside" CPU work time required between
finish and  start time of "RCX instruction loop" calls.
0.17 msec   CPU time used to execute a assignment statement ("j = 0")
0.35 msec   CPU time to execute a motor off command.
0.26 msec   CPU time to execute a cleartimer() command.

I ran each instruction type in three configurations to measure the impact of
multiple tasks operating. The configurations were with one, two and five
tasks operating simultaneously. The measured time (in msec) was:

# of Tasks        001             002          005
assignment      1.92           2.10         2.67
motor off           2.09           2.44         3.50
clearTimer        2.03          2.29          3.07

Solving the simple linear equation yielded the approximately 1.75 msec
overhead time plus the time for each opcode.

----------------------------------------------------------
For those interested, the actual program code used to perform the timing is
given below. It uses a (hopefully) about to be released for beta-testing
"C++ like" compiler. This code shows off a few of the capabilities of this
development system including:
   - class declarations for 'timer' and 'motor' types. The actual definition
and method statements are in an "#include" file. that is not shown. Base and
derived classes are supported. ['new' and 'delete' operators are not
supported!]
   - scope rules on variables with memory overlays / re-use where
appropriate
to maximize reuse the critical 32 memory variables of the RCX.
  - "for" loops.
  - inline procedures and functions. Use of inline procedure allows separate
instance of the "measureIt" procedure to be executing in each of the five
tasks and each instance has its own allocated local variables.


timer time(T1);
timer time2(T2);

motor left(A);

inline measureIt()
{
   int i, elapsed, loopOverheadTime;

elapsed = time;
//
//  Perform empty loop to calculate overhead of looping
//
for (i = 0; i < 500; ++i)
{}
loopOverheadTime = time - elapsed;
//
// Now perform the loop with instructions this time
//
elapsed = time;
for (i = 0; i < 500; ++i)
{
  left.off(); left.off(); left.off(); left.off(); left.off();
  left.off(); left.off(); left.off(); left.off(); left.off();
  left.off(); left.off(); left.off(); left.off(); left.off();
  left.off(); left.off(); left.off(); left.off(); left.off();
}
//
// Subtract out the loop overhead processing time and we have
// the time required to execute 10,000 instances of "left.off()"
//
elapsed = time - elapsed - loopOverheadTime;
return;
}
task secondTask()   {measureIt();}

task thirdTask()   {measureIt();}

task fourthTask()   {measureIt();}

task fifthTask()   {measureIt();}

{
time.clear();
setDisplay(1);
startTask(secondTask);
startTask(thirdTask);
startTask(fourthTask);
startTask(fifthTask);
measureIt();

setDisplay(3); // so we know when it is done
playSound(1);
return;
}



1 Message in This Thread:

Entire Thread on One Page:
Nested:  All | Brief | Compact | Dots
Linear:  All | Brief | Compact
    
Active threads in Robotics

 
Verified and Trusted Team of Hackers
11 hours ago
Custom Search

©2005 LUGNET. All rights reserved. - hosted by steinbruch.info GbR