The Netduino forums have been replaced by new forums at community.wildernesslabs.co.
This site has been preserved for archival purposes only
and the ability to make new accounts or posts has been turned off.
The most I once did was 50, but it became quite slow.
Keep in mind, it's multithreading, but in the way a single-core computer does, it devides cpu time over all threads.
I think the amount of threads is virtually unlimited, but performance will become a pain eventually.
I have switched to single threaded programming on my Netduino Go, because when theres 4-5 concurrent threads running, one or two of them never gets CPU cycles after a minute of operation. Then if I reboot, it might work for two minutes, next time maybe five, next time maybe not at all. Everything shared is thread safe, minimal writing/reading to SD/ethernet due to buffers.
And also... with 4-5 threads, it can take up to almost 14 seconds write 100 bytes to a SD card... the exact same code, when only 1 thread runs, it takes only a few milliseconds to write 1-2 kb.
When that said, thats when my uploader should be working constantly, and saving every few second. But compared to single threaded mode, those few threads has an insane impact on performance... Sometimes a it can also take a few seconds, or maybe a minute, before the Netduio changes to a specific thread.
They all have the same thread priority, but some threads get skipped when cycling!
thank you Nicky for that hint, and i wondered why my sd card is so slow.
with threads it took me 2.5!! seconds to read 128 bytes. without just 0.6 seconds (all same code, iam just calling all threads now from main loop)
when leaving all other threads but the sd card read in main loop, i got 1.5 secs
on an empty project its 0.4secs, so not much difference
thank you Nicky for that hint, and i wondered why my sd card is so slow.
with threads it took me 2.5!! seconds to read 128 bytes. without just 0.6 seconds (all same code, iam just calling all threads now from main loop)
when leaving all other threads but the sd card read in main loop, i got 1.5 secs
on an empty project its 0.4secs, so not much difference
Are you sure its just the threading? I'm running 4 - 5 threads at the same time, UDP listener, webserver, serial server, main thread and sometimes a background worker to store data, I notice no (big) performance disadvantages on a standard ND+.
You know you can set priorities on your thread? I assume you have something going on in your main thread (the starting one) that keeps the other from executing.
Are you sure its just the threading? I'm running 4 - 5 threads at the same time, UDP listener, webserver, serial server, main thread and sometimes a background worker to store data, I notice no (big) performance disadvantages on a standard ND+.
You know you can set priorities on your thread? I assume you have something going on in your main thread (the starting one) that keeps the other from executing.
Sounds like me and Noom are experiencing the same, so I can tell:
- Main-thread: Idle
- Every second, an event raises, refreshing sensors + screen and saves data (writes 100 bytes of json (automatic parsing)) if enough time has passed.
- When ever theres data to be sent, an uploader worker sends the file with a lightweight http request (1 request line, 3 line header, 100 bytes payload).
That is basicly whats killing my NGo ... singlethreaded, it can refresh, save and send data in less than a second. Multithreaded, it kills it self.
ntools TCP Listener (Beta) · FTP Server (Alpha) Netduino Plus Go Module · Xml Parser http://ntools.codeplex.com/
Hi Nicky,
We have some commercial projects which use several threads, with good response times, and run for months on end. So in theory, at least, threading should work well in NETMF
Most of our multi-threading issues that we've run into over the years are high MCU utilization (i.e. threads which don't give up much time for other threads to execute frequently) and garbage collection (due to thread objects and threads' objects going out of scope).
Is there any chance that you have a small sample app (perhaps one thread blinking the white led, one blinking the blue led, one blinking an LED on a digital port) which exhibits this behavior? If we can reproduce it, we can dig into the IL interpreter and coordinate with Microsoft on a fix (or determine why it's behaving as .NET is supposed to behave--there are always the garbage collection issues, etc.)
Chris