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 / 10065
10064  |  10066
Subject: 
Re: Multitasking
Newsgroups: 
lugnet.robotics
Date: 
Fri, 14 Jan 2000 18:25:31 GMT
Original-From: 
John A. Tamplin <JAT@LIVEONTHENET.spamcakeCOM>
Viewed: 
971 times
  
On Fri, 14 Jan 2000, David Leeper wrote:

I was thinking this over last night and was wondering about how sleeping a task
would affect an application that requires precise timing. In the bicycle
example, what would happen if the balancing task was asleep when the bicycle
began to tip?

I think multitasking is certainly useful in situations where the tasks are
disjoint, such as driving the robot and sending a message over the IR port. But
when the tasks need to work together closely, the sleeping issue worries me.

Actually, this is precisely the case where multitasking works best.  A
single-threaded application has to poll for events that it is interested in.
Regardless of the priority of a particular event, that event has to wait
until the application polls for it.  You can adjust this somewhat by polling
more important things more frequently, but it is still a problem.  For
example:
  while(1) {
if(out_of_balance()) { balance(); }
if(hit_something()) { avoid_obstacle(); }
/* ...other tests and actions... */
  }
If the out-of-balance condition occurs just after the test, but a bumper
is activated and avoid_obstacle runs, it will be way too late by the time
balance() gets called.

In a traditional multitasking environment, you have separate threads running
at appropriate priorities.  In your example, the balancing task would be one
of the highest priorities, while things like avoiding obstacles would be
lower and tasks like finding a target to shoot would be lower still.  Some
hardware detects that an out-of-balance condition exists, triggers an
interrupt, which wakes up the balancing thread.  Since it is the highest
priority thread, it runs immediately.

Note that this does not necessarily apply to all systems that are called
multitasking -- specifically the standard Lego software -- but this should
give you an idea of the value in a real-time environment.

John A. Tamplin LiveOnTheNet.COM, Inc.
jat@LiveOnTheNet.COM 2104 West Ferry Way
256/705-7007 - FAX 256/705-7100 Huntsville, AL 35801



Message has 1 Reply:
  Re: Multitasking
 
Hi John, I agree that on an interupt-driven system, multitasking is very useful for problems that require precise timing. As soon as the problem occurs, an interupt is fired and the appropriate code handles the problem. But, as you noted, the RCX (...) (25 years ago, 14-Jan-00, to lugnet.robotics)

Message is in Reply To:
  Re: Multitasking
 
Hi Alex, I was thinking this over last night and was wondering about how sleeping a task would affect an application that requires precise timing. In the bicycle example, what would happen if the balancing task was asleep when the bicycle began to (...) (25 years ago, 14-Jan-00, to lugnet.robotics)

9 Messages in This Thread:


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

This Message and its Replies on One Page:
Nested:  All | Brief | Compact | Dots
Linear:  All | Brief | Compact
    
Active threads in Robotics

 
Verified and Trusted Team of Hackers
5 hours ago
Custom Search

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