ROBOTC.net forums
http://robotc.net/forums/

Parallel Tasks problem
http://robotc.net/forums/viewtopic.php?f=11&t=4843
Page 1 of 1

Author:  team223 [ Mon Sep 17, 2012 9:48 am ]
Post subject:  Parallel Tasks problem

I've run into a problem with my code.
I know that normally, if you have a global variable, you can use it in a function, then use the return command to use it in other functions.
However, the return command does not work when used with parallel tasks. If I try to do so, I get the error "**Severe*:'void' function cannot return a value".

Is there a different command used to share variables in parallel tasks or is such an activity impossible?

An example of this situation would be:
Code:
int sharedvariable;
sharedvariable = 1;

task notmain()
 {
  while 1
   {
    sharedvariable = sharedvariable + 1;
    return sharedvariable;
    wait1Msec(100)
   }
 }

task main ()
 {
  motor[port1]  = sharedvariable;
 }

Author:  Spiked3 [ Mon Sep 17, 2012 11:38 am ]
Post subject:  Re: Parallel Tasks problem

you wouldn't need to return it, simply set it.
Code:
int sharedvariable;

task notmain()
{
   while 1
   {
      sharedvariable = sharedvariable + 1;
      wait1Msec(100)
   }
}

task main ()
{
        sharedvariable = 1;
   StartTask(notmain);
   while 1 {
      motor[port1]  = sharedvariable;
      wait1Msec(500);
   }
}

that is why the tasks are parallel, if that is what you really want to do. In this case (as is usually the case) it is probably not what you really want to do.

Author:  mightor [ Tue Sep 18, 2012 1:26 am ]
Post subject:  Re: Parallel Tasks problem

Just look at my signature what I think about multitasking.

- Xander

Author:  jbflot [ Mon Oct 01, 2012 2:32 pm ]
Post subject:  Re: Parallel Tasks problem

There's a decent post at the top of the forum about multitasking: viewtopic.php?f=11&t=3341

Page 1 of 1 All times are UTC - 5 hours [ DST ]
Powered by phpBB © 2000, 2002, 2005, 2007 phpBB Group
http://www.phpbb.com/