Pages: 1 [2]   Go Down
Author Topic: I'm not a troll but....  (Read 4709 times)
0 Members and 1 Guest are viewing this topic.
Rural Arizona
Offline Offline
Edison Member
*
Karma: 7
Posts: 1711
Incorrigible tinkerer
View Profile
 Bigger Bigger  Smaller Smaller  Reset Reset

No you only get true multitasking with multiple cores
No, that's "multiprocessing".  This Wikipedia article gives a good explanation of the differences among the various "multi-"s.

You might say that multitasking is "virtual multiprocessing":  like "virtual memory" or "virtual machines", it provides the illusion of having more physical resources.
 


Logged

Forum Administrator
Offline Offline
God Member
*****
Karma: 52
Posts: 639
I find plain exciting
View Profile
WWW
 Bigger Bigger  Smaller Smaller  Reset Reset

@perkunas

a couple of comments.
1. the linux IDE surely could use some love but it's also a nightmare to get it to work with all these different permutations of distributions and packages etc 
2. It really depends on what is your style of programming. If you've learned on a modern computer and are used to multithreading, multitasking and all of that, clearly Arduino seems very limited but if you apply different coding patterns  you can get a LOT of mileage out of it. I teach my students about state machines all the time, I just don't tell them they are called like that and they can implement them very easily.

PS: I learned on a ZX81 which had 1kb of ram and Arduino is like a Ferrari compared to that smiley

m
Logged

Pittsburgh, PA, USA
Offline Offline
Faraday Member
**
Karma: 94
Posts: 4758
I learn a bit every time I visit the forum.
View Profile
 Bigger Bigger  Smaller Smaller  Reset Reset

2)Halfway through the program I found it impossible to multithread and multitask, something you want to do after your 1st blinky.
Oh sure you can write a state machine, or some other trick but that's not true multitasking, confusing totally impractical.

Yet another modern PC programmer who does not understand state machines. No surprise there.

What Mike said, you need multiple cores to do "true multitasking". Which is possible with Arduino when you add MCU's... I'd go for SPI or I2C bus and some extra 1-wire bus comms as needed but the real question is why for a task like yours? Organized and written properly it should be well within the capabilities of an Arduino.
Logged

I find it harder to express logic in English than in Code.
Sometimes an example says more than many times as many words.

Forum Administrator
Offline Offline
God Member
*****
Karma: 52
Posts: 639
I find plain exciting
View Profile
WWW
 Bigger Bigger  Smaller Smaller  Reset Reset

the arducopter/ardupilot code should provide a good example of how far you can stretch the hardware of an Arduino smiley

m
Logged

Ayer, Massachusetts, USA
Offline Offline
Edison Member
*
Karma: 53
Posts: 1832
View Profile
WWW
 Bigger Bigger  Smaller Smaller  Reset Reset

2)Halfway through the program I found it impossible to multithread and multitask, something you want to do after your 1st blinky.
Oh sure you can write a state machine, or some other trick but that's not true multitasking, confusing totally impractical.

Yet another modern PC programmer who does not understand state machines. No surprise there.

What Mike said, you need multiple cores to do "true multitasking". Which is possible with Arduino when you add MCU's... I'd go for SPI or I2C bus and some extra 1-wire bus comms as needed but the real question is why for a task like yours? Organized and written properly it should be well within the capabilities of an Arduino.
No, you don't need multiple cores to do "true multitasking".  You just need enough memory to allow each thread to run in its own stack frame, and something to do the switching.  There are various thread models that use cooperative threads.

That assumes you are in control of all of the software, and don't use pre-written libraries that use delays.  For example as say the Morse code library and the IR library both do, and which I want to marry together (I have a camera shutter release, that wants to fire off a message in Morse code, but I want to be able to stop the beeping if I get a button press, either a direct button or a button with an IR transmitter).  Yes, I eventually will take the source to both, and rewrite them to use state machines, but it would have been a lot simpler if I didn't have to write everything from scratch, and I can just use the libraries as is.  Both state machines and threads are tools in the toolbox.  Sometimes one is better than the other.
Logged

Central MN, USA
Offline Offline
Tesla Member
***
Karma: 72
Posts: 7171
Phi_prompt, phi_interfaces, phi-2 shields, phi-panels
View Profile
WWW
 Bigger Bigger  Smaller Smaller  Reset Reset

As far as I know about multitasking, not all threads have to be running simultaneously. Think about time-share property (or time-division multiplexing for cell phone people) as a parallel to multitasking on a single processor. IIRC, Intel's first true multitasking processor was the 80386, with hardware dedicated to multitasking, privileges, and virtual memory management, all of which are necessary to make an effective multitasking operating system. I don't know what MCU has that capability nowadays but multitasking is not just hardware but also sophisticated software that organizes tasks and relies on hardware to make each task feel like it is the only task running (virtual memory management for chaining up fragmented memory, memory/hard drive swap, and machine state save and recall etc.) and prevent unauthorized access to memory and other resources by tasks that don't have the privileges. Trying to do simple things all at the same time with multitasking is trying to kill mosquitoes with a canon. The OP may have programmed a general purpose computer for too long and he overlooked the fact that modern computers started not much more capable than arduino (8-bit, little memory) decades ago and back then people controlled multiple things just fine without multitasking software or hardware.

FYI, 80386 had a maximal memory of 4GB and virtual memory space of 64TB. I wonder if any lucky 386 has ever got close to that amount of memory.
Logged


Offline Offline
God Member
*****
Karma: 7
Posts: 647
"In this house, we obey the Laws of Thermodynamics" Homer J. Simpson
View Profile
 Bigger Bigger  Smaller Smaller  Reset Reset

Quote
No, you don't need multiple cores to do "true multitasking".  You just need enough memory to allow each thread to run in its own stack frame, and something to do the switching.

I disagree. By "true multitasking" people mean threads are really running in parallel - or at least that is what I mean  smiley

If you have a single core switching between threads then the illusion is given that things are happening in parallel but the reality is that threads are being processed sequentially even if you are allocating a higher priority and more processor time to some threads. The Arduino can multitask (in what I think is the normal sense of the word) , but it is not "true multitasking".
Logged

South Texas
Offline Offline
Edison Member
*
Karma: 8
Posts: 1024
View Profile
 Bigger Bigger  Smaller Smaller  Reset Reset

True multi-tasking is 1 processor running various tasks in their own time slot. We have gotten used to Multi-processing with cheaper and cheaper silicon and the resulting ability to pack more in less space. But much of it still boils down to one processor doing several things in sequence, and doing it so fast that it looks like many things are happening in real time.

This has been going on for many years. My first multitaking system was an Allen-Bradley PLC (programmable logic controller) which was able to control various parts of a machine, asynchronously. It ran a tight control loop that executed 535 time a second. Close enough to be called real time. Read an encoder through 12 digital inputs, Had about 48 switch inputs for the various parts of the machine, approx 24 outputs for various motors and solenoids. Had 4 separate subsystems all running their own control sequence at the same time.

It is interesting that with Arduino and such we are just going back to the early days of industrial PLC control. 1 processor managing some I/O and making things do their stuff based on some logic and some inputs.
Logged

Central MN, USA
Offline Offline
Tesla Member
***
Karma: 72
Posts: 7171
Phi_prompt, phi_interfaces, phi-2 shields, phi-panels
View Profile
WWW
 Bigger Bigger  Smaller Smaller  Reset Reset

It is interesting that with Arduino and such we are just going back to the early days of industrial PLC control. 1 processor managing some I/O and making things do their stuff based on some logic and some inputs.

True until you look at who were using PLCs and who are using arduinos and the level of difficulty using PLC vs. arduino  smiley-razz

I thought multitasking was a fancy word for time-division multiplexing with programs. It's always about one unit trying to serve the needs of many. Some people may have confused multitasking with parallel computing, where multiple tasks could be carried out by multiple units at the same time.
Logged


Offline Offline
Newbie
*
Karma: 0
Posts: 1
View Profile
 Bigger Bigger  Smaller Smaller  Reset Reset

Gentlemen, gentlemen. If concurrency without interrupts or convoluted schedulers is desired, humbly suggest you look at the Propeller chip/boards (at parallax.com). It's 32 bit with 8 cores that run truly in parallel at 80 Mhz. You no longer have to program it in SPIN or assembly, as there's a new Win/Mac/linux C/C++ IDE (coded in C w/ Qt not slow Java). Break up problems into parallel tasks between the 8 cores. All Prop pins are general purpose. On a Prop if you need a UART, you load up UART code into a core, let 'er rip, read and write data via shared memeory. Need VGA out? Dedicate a core, add a few resistors. The chip is $7. There are also Arduino shield compatible Boards, like the ASC+ (with a lot of goodies) at $49. Nice.
Logged

Pittsburgh, PA, USA
Offline Offline
Faraday Member
**
Karma: 94
Posts: 4758
I learn a bit every time I visit the forum.
View Profile
 Bigger Bigger  Smaller Smaller  Reset Reset

It looks like applications are loaded into RAM only.. I see no place a program is stored on-chip power-off, ie no flash but hey with external EEPROM it can be used without a PC to load from?

With 8 cores and all the doo-dahs I would like a lot more RAM given that's code and data space.

It definitely has uses Arduino can't easily fill, has a niche, just not the same as AVR nor as cheaply in general.


Logged

I find it harder to express logic in English than in Code.
Sometimes an example says more than many times as many words.

Global Moderator
Offline Offline
Brattain Member
*****
Karma: 474
Posts: 18696
Lua rocks!
View Profile
WWW
 Bigger Bigger  Smaller Smaller  Reset Reset

Even multiple cores aren't the golden bullet some people seem to think they are. Multitasking, multiprocessing, multiple cores, multiple boards, whatever.

If they are on the same project they have to work together. There will be a shared resource of some sort or it isn't the same project. Typically multiprocessor systems share the same RAM and the same hard disk. So now you have to compete for that resource. You need critical sections, semaphores, locks, unlocks, etc.

This introduces complexity. It also introduces the possibility of race conditions, where A waits on B and B waits on A, and nothing happens.

The fact is that the Arduino can do quite complex stuff. For example, I've done VGA video output which requires precise timing. Others have done line-following robots, beer brewing machines, helicopters, etc.

I've done an Adventure game where the processor accepts input, and displays information on the screen.

If you think you have to replace your Arduino because you need to do something more complicated than blink an LED, you haven't understood how to make it work, that's all.

There are some limitations, there will be with anything. The basic speed of the processor means you won't be doing 3D graphics in a  big hurry at high resolutions. But what do you expect for $5?
Logged

Pages: 1 [2]   Go Up
Jump to: