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 / 406
405  |  407
Subject: 
LegOS 0.2.0a multi-threading problem
Newsgroups: 
lugnet.robotics.rcx.legos
Date: 
Mon, 25 Oct 1999 16:23:47 GMT
Viewed: 
793 times
  
I have been attempting to us the thread API for a LegOS project.  I have been
following the examples I found on the LegOS How-To page with out much success.

If I run some simple code inside the main function it works fine but if I try
the same code inside a thread and call it with execi() the RCX locks up.

Here is the code (with the thread model):

// I expect this code to start the motors forward for two seconds and then exit
// Instead when the code it executed the RCX stops responding and need a
// battery removed to clear its memory.

#include "conio.h"
#include "unistd.h"
#include "dkey.h"
#include "dsensor.h"
#include "dmotor.h"
#include "sys/tm.h"
#include "rom/system.h"


pid_t t1;

int rover (int argc,char **argv) {

  motor_a_speed(MAX_SPEED);
  motor_c_speed(MAX_SPEED);

  motor_a_dir(fwd);
  motor_c_dir(fwd);

  cputs("fwwd ");

  sleep(2);

  motor_a_speed(off);
  motor_c_speed(off);

  return 0;
}

int main()
{

  t1=execi(&rover,0,NULL,1,DEFAULT_STACK_SIZE);

  tm_start(); /* starts t1 */

  return 0;
}



Message has 1 Reply:
  Re: LegOS 0.2.0a multi-threading problem
 
(...) [snip] Heh. I've spent 2 days on this, so I know how you feel :). main() must be the first function in your source file, otherwise really weird stuff happens. -- Regards, Modemch (25 years ago, 25-Oct-99, to lugnet.robotics.rcx.legos)

2 Messages 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