muiltithreading

All software questions and discussions on any Language

Moderators: myblack60impala, ken tait

muiltithreading

Postby gifted on Fri Mar 05, 2010 6:55 pm

I saw that there wasn't much on this around. I got my first aruino a bit back, and some of the components to use today. So, I have the opportunity this weekend to start really digging in. The big thing is, the first "project" I was looking at was a traffic light setup. We looked at one of these in intro to electronics for introducing microcontrollers, and I figured a slightly more complex one would be ideal to play with a reasonably large program doing a bunch of stuff, but not worrying about motors or anything.

Thing is, the processing based language(there's supposed to be a C IDE, right? Didn't see it on the site) I got to start with doesn't seem to support multithreading, which is necessary if you're looking at more than one input that do more than one thing at a time. I found a few options for multithreading, or "protothreading" according to one, but haven't tried anything as of yet. I thought I'd post what I'd found, and see what others suggest.

http://concurrency.cc/
concurrency is apparently specifically designed for the arduino, though it's not out for windows yet. I'll have to see about doing the work to make it happen.

http://www.arduino.cc/playground/Code/TimedAction
TimedAction is a library for the C environment, but doesn't seem to be true multithreading, more a tool to make it happen. As well, a few places I looked said that C doesn't support multithreading, not sure about C#.

Processing itself seems to have a few options, but I'm not sure how they'll move over to the arduino programmer.

anyone have any other ideas? It'd be nice if there was a compiler/linker for C++ and visual studio, I can get help with C++ easier since I'm in that class.
Evil is evil, no matter how small.
User avatar
gifted
Robosapien
 
Posts: 126
Joined: Fri Feb 01, 2008 12:44 am
Location: Overland, MO

Re: muiltithreading

Postby tmaiden on Sat Mar 06, 2010 6:50 am

True concurency is achived by having a one processor for every function. That way, they really do all run at exactly the same time.

This is why big servers have multiple processors. This is why INTEL builds CPUs with multiple cores. ( check out their new I7 chip)

To do "multi-tasking" on a single processor, you need a program that keeps track of multiple jobs ( processes) and switches the cpu between each job, a little bit at a time. Every job takes its turn, then has to get out of the way for the next job.

This requires enough on board memory for each job - Or it requires Off chip memory ( Cache) - Or it requires virtual memory ( a swap file on a hard drive)

You could write code to do this on a Micro controller, but you lack the hardware to support all of the above. You might want to look at a CPU chip like a
zilog Z-80 ( or modern equivilent) - or just use a PC motherboard and an existing operating system.

Whats the difference between Multi-threading and multi-tasking? Multi-threading requires that one thread can be syncronized with the other so that data from one thread can be used by the other. Usually syncronizing means that one thread must wait until the other thread is ready for it.

[ REMINDER - Verify everything I say before spending any money ]
= Tom M. =

An objects mass is the result of the viscosity of the 4 dimensional space-time fabric.
User avatar
tmaiden
R. Daneel Olivaw
 
Posts: 1174
Joined: Mon Apr 04, 2005 4:34 pm
Location: So. Saint Louis County, MO, USA

Re: muiltithreading

Postby gifted on Sat Mar 06, 2010 5:40 pm

Most of the places I was looking at seemed to consider multithreading a more general term. Perhaps multitasking would be more suited to what I want to do. A couple places used the term "protothreading" since it wasn't on the hardware level.

In lab we had a traffic light simulator with leds and switches. When you flipped a switch, it waited for the entire loop to finish before getting back and seeing that the switch was hit. I'm setting up a more complex one for programming practice(this would be a nice entry level program--needs to do several things, but isn't super difficult to build/program), and I'd like to be able to get things going separately.

The sites I posted show several ways to due several things at once in various ways, but I think concurrency is the leader for ability. All the others force you to implement the threading yourself--you can't just say to make a task a separate thread. I also can't see why this isn't available, whatever it should be called. I can use timedaction and the like, but it seems I'll be writing a lot more code with something like that than I should be.

I do plan to use a single board computer for a robot brain, but that's probably several years down the road. For now it's an Arduino Mega, and eventually Xigbee from it to the netbook.
Evil is evil, no matter how small.
User avatar
gifted
Robosapien
 
Posts: 126
Joined: Fri Feb 01, 2008 12:44 am
Location: Overland, MO


Return to Software

Who is online

Users browsing this forum: No registered users and 1 guest