Programming Notes Linux vs Arduino
After completing the "technology upgrade" of the LPCR to include the Arduino, I think I have to make a note about the different strategies of the two platforms.
Linux is a powerful multitasking system. It has powerful features such as multiple processes, shared memory, multiple threads within processes, lots of memory, and formalized disk access. As a multitasking system, many programs compete for resources such as CPU time, memory, and I/O.
The strategy, therefore, is to block on I/O. Have different threads or processes for different jobs or tasks. Release CPU when you need to wait with select, poll, wait or even sleep. Use mutexes, semaphores, and events or condition variables for synchronisation. You can use select or poll to manage process timing.
The Arduino, on the other hand, is a small system. It has one task. Programs have the whole computer to itself, you don't need to share. As one task, you have to manage multiple tasks yourself. You have to take care of timing yourself.
The two systems, while both coded in C++, require very different programming strategies.