0
Offline
God Member
Karma: 0
Posts: 596
Arduino rocks
|
 |
« Reply #30 on: April 19, 2011, 10:42:40 am » |
Brig, while I find the (software) threads concept quite fascinating, after reading this (interesting) (forum) thread I still can't understand what is wrong about "polling" the RTC time inside loop(). If you want to practice with threads on the Arduino, fine. But if your main goal is use the Arduino to manage an acquarium, then do yourself a favor and totally forget about threads. There is the excellent Time library, which maintains the current time either via millis() or communicating with an RTC clock via I2C. This is 99% transparent, i.e. you can code to it and switch back and forth from an RTC to a RTC-less sketch in no time. It's an excellent choice for periodic tasks. Other libraries exists in the Playground that are equally good, although not as complete.
HTH
|
|
|
|
|
Logged
|
|
|
|
|
Massa, Italy
Offline
Full Member
Karma: 0
Posts: 172
Arduino rocks
|
 |
« Reply #31 on: April 19, 2011, 12:40:28 pm » |
for didactic reasons I got used to the thread, and as long as this simple things I immediately use they natural ...
I repeat, my problem is a particular case, but should be seen in a wider range, where perhaps one can also do something nice ... For example, alter the input from the numeric keypad (the phone), leaving a thread waiting on readChar even do a poll ... I find it more appropriate
and then repeat, not a problem, insert the line "RTC.refresh ()" it's just that I would rather not do it, because a programmer who uses my library can forget it, and before finding this little error... while if launch a thread that makes it alone, putting a mutex from Lokke on each access to the variables of RTC ... would be more simple and straightforward ...
personally if I had time, more knowledge of assembler and C more knowledge in general, I'll try to implement them willingly thread on arduino as good exercise!
|
|
|
|
|
Logged
|
|
|
|
|
SF Bay Area (USA)
Offline
Faraday Member
Karma: 78
Posts: 5455
Strongly opinionated, but not official!
|
 |
« Reply #32 on: April 19, 2011, 04:30:12 pm » |
In general, the problem with multithreading on a small microcontroller like the AVR is that there is not enough RAM. A complete process context (32 registers + PC + stack + stack pointer is probably over 100 bytes, and the atmega328 chip used on Arduino only has 2k total.
|
|
|
|
|
Logged
|
|
|
|
|
|
|
Red Sea, Saudi Arabia
Offline
God Member
Karma: 11
Posts: 579
..On The Red Sea
|
 |
« Reply #34 on: April 30, 2011, 12:19:06 pm » |
And add to those 2, QNX which has been implemented on many much slower processors than the ATMEGA328 and which is running thousands of automatic machines of one kind or another in industry today. Other viable RTOS kernels have been implemented on processors from the 6502/6800 onwards. I even wrote one in 1980 that pretty much worked  And I wrote lots of EDX based code on Series/1 with only 64K of memory, in the same era. The main points about 'threads' or 'tasks' like: "Threads, as a model of computation, are wildly nondeterministic" is an argument against nondeterministic coding, not threads. This is exactly why the QP Framework is based on the idea that all threads MUST be Finite State Machines. This is a concept that I was able to enforce (Oh, Um, technically lead?) in Semiconductor manufacturing in one IBM plant in the 1990's.. and it DID decrease the instances of "wildly nondeterministic" code. Requiring that network communications interfaces to process equipment be documented as Finite State Machines was finally accepted practice. One grudging response was "I think we wasted some time using (this method) but it did make debugging a lot easier". That said, I DID write a communications protocol using the approach which seemed to work OK and went into production and after it was running on about 20 systems for a few months it became clear that it occasionally crashed. Ugg... Finally my friend Tony Burke (Who I am glad to credit years later!!!) found the bug. So nothing is sacred and nothing is perfectly error free. In a similar way, Proof is in the nontrivial application running clean for 1000 hours. Anyone writing some QP FRamework stuff on the free Arduino version? I HOPE to get some time on this even though I should be writing other stuff. "But Mom, I LOVE writing RTOS stuff  it's SO cool." And the .NET guys and the IphoneAPP guys don't know WHAT the hell you're even talking about...
|
|
|
|
|
Logged
|
|
|
|
|
SF Bay Area (USA)
Offline
Faraday Member
Karma: 78
Posts: 5455
Strongly opinionated, but not official!
|
 |
« Reply #35 on: April 30, 2011, 03:19:44 pm » |
QNX which has been implemented on many much slower processors than the ATMEGA328 How do you figure? I thought the smallest thing QNX ran on was a relatively good-sized x86? In any case, "slow" isn't the problem. RAM is the problem. There are lots of nice multitasking systems that run fine on a system with 256K of RAM, but will have big problems on a system with 256K of flash and 8k of RAM...
|
|
|
|
|
Logged
|
|
|
|
|
Red Sea, Saudi Arabia
Offline
God Member
Karma: 11
Posts: 579
..On The Red Sea
|
 |
« Reply #36 on: May 01, 2011, 12:01:10 am » |
QNX which has been implemented on many much slower processors than the ATMEGA328 How do you figure? I thought the smallest thing QNX ran on was a relatively good-sized x86? Maybe I'm older than you  Today QNX is supported on ARM, PowerPC and X86 etc, and now on the Blackberry Tablet But 25 years ago QNX did run on some of the earlier microprocessors that existed then. I'll try to find a reference, other than my recall of semiconductor process equipment running it... Modern QNX has features that could never be supported on machines with very limited memory... But the QP framework has working examples running on Arduino, so they have some stuff figured out for 2011. I'd mainly like to see some set of known solutions for Arduino beginners to start to encounter apparent concurrency without going back to school to learn about interrupt latency and directed graphs.
|
|
|
|
|
Logged
|
|
|
|
|
nr Bundaberg, Australia
Offline
Tesla Member
Karma: 73
Posts: 6841
Scattered showers my arse -- Noah, 2348BC.
|
 |
« Reply #37 on: May 01, 2011, 12:17:35 am » |
We used QNX for building control on a 6809-based computer in the 80s, I don't remember the details but it's probably fair to say it had 64k RAM.
One assumes though that QNX has gone the bloatware track like everything else. ______ Rob
|
|
|
|
|
Logged
|
|
|
|
|
Global Moderator
Melbourne, Australia
Offline
Shannon Member
Karma: 219
Posts: 13897
Lua rocks!
|
 |
« Reply #38 on: May 01, 2011, 12:55:19 am » |
Ah, the old 6809. I like the Wikipedia article about it, in particular the HCF instruction (Halt and Catch Fire). http://en.wikipedia.org/wiki/Halt_and_Catch_FireI don't suppose the Atmega has one of those?
|
|
|
|
|
Logged
|
|
|
|
|
Red Sea, Saudi Arabia
Offline
God Member
Karma: 11
Posts: 579
..On The Red Sea
|
 |
« Reply #39 on: May 01, 2011, 01:57:17 am » |
We used QNX for building control on a 6809-based computer in the 80s, I don't remember the details but it's probably fair to say it had 64k RAM. ...
Thanks for validating that my personal memory is still retrieving! Hadda be someone associated with "Gray", I guess..
|
|
|
|
|
Logged
|
|
|
|
|
nr Bundaberg, Australia
Offline
Tesla Member
Karma: 73
Posts: 6841
Scattered showers my arse -- Noah, 2348BC.
|
 |
« Reply #40 on: May 01, 2011, 02:39:30 am » |
And then there was XPR (eXecute PRogrammer) LDN (LoaD Nothing) and a lot of other funny ones around a few years ago.
______ Rob
|
|
|
|
|
Logged
|
|
|
|
|
|
|
Global Moderator
UK
Offline
Brattain Member
Karma: 138
Posts: 19067
I don't think you connected the grounds, Dave.
|
 |
« Reply #42 on: May 01, 2011, 04:40:01 am » |
And then there was XPR (eXecute PRogrammer) My personal favourite was the PowerPC's EIEIO instruction
|
|
|
|
|
Logged
|
Pete, it's a fool looks for logic in the chambers of the human heart.
|
|
|
|
nr Bundaberg, Australia
Offline
Tesla Member
Karma: 73
Posts: 6841
Scattered showers my arse -- Noah, 2348BC.
|
 |
« Reply #43 on: May 01, 2011, 04:49:06 am » |
That was on the Old MacDonald variant of that processor wasn't it?
______ Rob
|
|
|
|
|
Logged
|
|
|
|
|
Global Moderator
Melbourne, Australia
Offline
Shannon Member
Karma: 219
Posts: 13897
Lua rocks!
|
 |
« Reply #44 on: May 01, 2011, 04:51:06 am » |
My personal favourite was the PowerPC's EIEIO instruction
So you are not referring to: A "computer bought the farm" message is an error message displayed on GNU Hurd when one of the servers that provide kernel-like functions reaches a "hopeless" situation (after which it is usually terminated). This is a rough equivalent of a kernel panic in monolithic Unix-like kernels. Its corresponding error code is the Hurd-specific EIEIO, a reference to the folk song Old McDonald Had a Farm.
But rather: Enforce In-Order Execution of I/O is an assembly language instruction used on the PowerPC computer processor used to prevent one memory or I/O operation from starting until the previous memory or I/O operation completed.
So, "do things in the order I tell you to"?
|
|
|
|
|
Logged
|
|
|
|
|
|