Abstract

The most popular platforms for developers of embedded systems among beginners are Arduino and Raspberry Pi. These platforms are different and have different purposes, but both may need to perform multiple operations in parallel. The article shows ways to implement multitasking on the above-mentioned platforms. Since Arduinos are mostly based on single-core AVR microcontrollers, with a rather low clock frequency, the multitasking of this platform is only conditional. Time-consuming operations will occupy the only core and the only thread of the microcontroller, which will not allow doing anything else. This does not apply to the hardware components of the microcontroller, such as timers, which work independently from the software part and allow the implementation of short tasks with a fixed period. There are libraries for simply writing a program that uses such controller capabilities. The most famous of them is TimedAction, which can be found on the official Arduino website. Also, most microcontrollers have a hardware input that can be used to generate software interrupts. During the interruption, operations can also be performed, after the completion of which the work of the main loop of the program will be resumed. On the Raspberry Pi, as on similar microcomputers running the Linux OS, you can fully consider threads and processes. A process is an instance of a program and is created by the operating system. Individual processes do not share a common memory. Parallel processes are used when complex calculations need to be accelerated. Threads are subtasks, which can be several within a process. There is a common amount of memory between several threads, which allows convenient data exchange. Parallel threads are used when you need to perform long I/O operations. In the Python language, which is widely used in embedded systems, the Threading library is used to implement multithreading. A feature of multitasking in Python is the Global Interpreter Lock. This mechanism ensures that the code of only one application process will be executed at a time. This feature of Python has supporters and detractors, as well as advantages and disadvantages.

Full Text
Published version (Free)

Talk to us

Join us for a 30 min session where you can share your feedback and ask us any queries you have

Schedule a call