To LUGNET HomepageTo LUGNET News HomepageTo LUGNET Guide Homepage
 Help on Searching
 
Post new message to lugnet.robotics.handyboardOpen lugnet.robotics.handyboard in your NNTP NewsreaderTo LUGNET News Traffic PageSign In (Members)
 Robotics / Handy Board / 8123
8122  |  8124
Subject: 
revised msleep() function for standard IC library
Newsgroups: 
lugnet.robotics.handyboard
Date: 
Thu, 12 Oct 2000 17:56:28 GMT
Viewed: 
983 times
  
        Based upon a student suggestion in our Autonomous Robotiics course
Subject: revised msleep() function for standard IC library
here at CWRU, I have written a new, multitasking-friendlier version of the
msleep() function.  The old version was a CPU-intensive busy loop.  The new
version does an immediate defer() if the sleep timer has not yet expired.

void msleep(long msec)
{
    /* replaced 12 October 2000 by RFD, new in v.2.67 */

    long end_time;

    end_time = mseconds() + msec;

    while (mseconds() < end_time)
        defer();                    /* this is the key change; */
                                    /* no foreground busy-wait */
}

Benchmark tests in a 6-process system (1 main(), 4 operating motors with
0.5 second sleeps between each command, 1 incrementing a long counter)
showed 300% more throughput for the counter process, with 30% of the
over-sleep error time, compared to the old version.  That is, over a fixed
operating time interval, non-sleeping processes were able to do 3x more
work, and the error in the times spent sleeping (always an overage, as the
sleep is a *minimum* time) was only 1/3 as great.  For sensor-intensive
multitasking programs, this is a significant improvement.  For single-tasking
programs, there does not appear to be significant additional overhead.

        For Handy Board systems, replace the code in lib_hb.c (or equivalent).
For 6.270 systems, replace the code in lib_r22.c (or equivalent).

        Comments and bug reports are welcome.

        *Rich*



1 Message in This Thread:

Entire Thread on One Page:
Nested:  All | Brief | Compact | Dots
Linear:  All | Brief | Compact
    

Custom Search

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