To LUGNET HomepageTo LUGNET News HomepageTo LUGNET Guide Homepage
 Help on Searching
 
Post new message to lugnet.robotics.rcx.legosOpen lugnet.robotics.rcx.legos in your NNTP NewsreaderTo LUGNET News Traffic PageSign In (Members)
 Robotics / RCX / legOS / 2222
2221  |  2223
Subject: 
Re: threads - bug in the firmware?
Newsgroups: 
lugnet.robotics.rcx.legos
Date: 
Fri, 18 Jan 2002 10:11:14 GMT
Viewed: 
2020 times
  
On Thu, 17 Jan 2002, Michael Obenland wrote:

   pid1 = execi (&bumper_task, 0, NULL, PRIO_NORMAL+4, DEFAULT_STACK_SIZE);
   pid2 = execi (&left_task,   0, NULL, PRIO_NORMAL+2, DEFAULT_STACK_SIZE);
   pid3 = execi (&right_task,  0, NULL, PRIO_NORMAL,   DEFAULT_STACK_SIZE);
   while( 1 );     // <<<<<<<<<<<<< this is crucial!

I would strongly suggest changing this to while(1) msleep(bignumber);.
Otherwise you're hogging the processor doing nothing important, which
could do bad things to any compute-intensive tasks you may have going.
It'll also use slightly less battery power this way since the OS would
probably be able to sleep the processor here and there. Not that this is a
large effect.

--
"From now on, we live in a world where man has walked on the moon.
And it's not a miracle, we just decided to go." -- Jim Lovell

Mike Ash - <http://www.mikeash.com/>, <mailto:mail@mikeash.com>



Message has 1 Reply:
  More on threads
 
(...) Of course you are right. I think it is a bad programming style not to give your program the ability to terminate but to run in an endless loop. But what is the penalty for this bad style? I've done some investigations and here are the results: (...) (23 years ago, 18-Jan-02, to lugnet.robotics.rcx.legos)

Message is in Reply To:
  Re: threads - bug in the firmware?
 
Hi Mike, your problem is not because of an error in legOS. But what you do is that you start your subroutines and then you leave main()! Leaving main means that all your allocated memory is freed. The following will do the job: ---...--- cut here (...) (23 years ago, 17-Jan-02, to lugnet.robotics.rcx.legos)

18 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
    

Custom Search

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