So I just wandered why it's possible to perform multi-threading/parallel programming on the nxt (e.g. using the tasks in nxc) but this is not possible on arduino (or is it?).
Has the "task" system been implemented in nxc through 'software/programming tricks' or is it to do with the hardware?
p.s. on a completely separate note:
If anyone can help with this problem I'm having with an nxt-arduino robot which i posted on the arduino forum (since its more an issue with the arduino) I would be grateful.
http://arduino.cc/forum/index.php/topic,101091.0.html
Thanks.
multi-threading possible on nxt but not arduino; why?
-
- Posts: 290
- Joined: 03 Oct 2011, 00:06
- Location: Gallifrey
- Contact:
Re: multi-threading possible on nxt but not arduino; why?
Unless you have multiple CPUs, multitasking is not *really* possible. It's typically done by just going round' through the tasks, and executing them one at a time, running each one for a certain amount of time.
A more in-depth look:
A more in-depth look:
A.K.A. NeXT-Generation.
"A kingdom of heaven for RobotC now has recursion!"
"A kingdom of heaven for RobotC now has recursion!"
Re: multi-threading possible on nxt but not arduino; why?
The NXT's firmware implements multi-tasking by effectively scheduling different tasks to make use of the processor. So basically, if you have 8 tasks, they each get a tiny amount of time to do their thing before they're suspended, allowing the next task to use the CPU (and other resources). So it's a bit like a round-robin effect.photon-1 wrote:So I just wandered why it's possible to perform multi-threading/parallel programming on the nxt (e.g. using the tasks in nxc) but this is not possible on arduino (or is it?).
It's all done in software, like on most single-processor systems. Even on multi-processor systems you still use the standard scheduling method for allowing the apparent running of many processes or tasks simultaneously.Has the "task" system been implemented in nxc through 'software/programming tricks' or is it to do with the hardware?
You should check out http://www.state-machine.com/arduino/index.php, which is an awesome framework for implementing event driven systems and multi-tasking. You can also chose to use a small RTOS on your chip: http://www.femtoos.org/index.html. The QP framework (in the first link) also has a small RTOS if you chose to use the baremetal instead of the Arduino Framework.
- Xander
| My Blog: I'd Rather Be Building Robots (http://botbench.com)
| RobotC 3rd Party Driver Suite: (http://rdpartyrobotcdr.sourceforge.net)
| Some people, when confronted with a problem, think, "I know, I'll use threads,"
| and then two they hav erpoblesms. (@nedbat)
| RobotC 3rd Party Driver Suite: (http://rdpartyrobotcdr.sourceforge.net)
| Some people, when confronted with a problem, think, "I know, I'll use threads,"
| and then two they hav erpoblesms. (@nedbat)
-
- Posts: 1818
- Joined: 02 Oct 2010, 02:19
- Location: Michigan USA
- Contact:
Re: multi-threading possible on nxt but not arduino; why?
NXT multitasking seems to have already been explained, so I'll only mention Arduino multitasking. The Arduino framework doesn't have support for multitasking in general, but there is a way you can sort of trick it into simple multitasking. You need to use timer interrupts. This is what I did for my PFIR library, so that it could transmit IR messages while still running the main task. However, it can get extremely complicated to implement it all in the user-program. In the case of my PFIR library, I only needed to have one extra task running along side of the main task. I had to completely manually add the return points and also the re-triggering. If you want to take a look at my implementation, here is a page that explains the user-side, and also has a link to the download.
Matt
http://mattallen37.wordpress.com/
I'm all for gun control... that's why I use both hands when shooting
http://mattallen37.wordpress.com/
I'm all for gun control... that's why I use both hands when shooting
Who is online
Users browsing this forum: No registered users and 2 guests