Posts: 1
Joined: Sat Oct 12, 2019 5:26 pm

Management of multiple tasks

Sat Oct 12, 2019 5:42 pm

Hi everybody,
I'm developing a project that requires the execution of multiple tasks doing very different things. Moreover, the tasks need to communicate with each other to exchange data and be synchronized.
For example, I have to run some video on a screen while communicate through a serial port, and based on what I've received from the serial port I might change the video to be displayed.
What is the best solution here? I've thought of 2 options:
1) Create a big single project in a specific programming language (e.g., Python) and use a multi-threading/multi-processes library?
2) or create different COMPILED programs run by an higher level super-advisor (e.g., a scheduler), however this super-advisor needs to ensure the communication and synchronization between the different programs.

Thanks for your time :D


Re: Management of multiple tasks

Sat Oct 12, 2019 5:54 pm

I like single programs doing single tasks as they are easier to debug.

They are not as efficient due to overheads of running programs but multi-threaded programs can be a pain to debug if you get random locks.

If I have a multitasking need I either use
1) Python queue module to communicate within the same program between tasks
2) MQTT. To communicate across programs - often with the broker being local to the Pi the program is running on

The bit that worries me over the queue module is the warning in it that the queue may not have an entry in it even though it has told you it does. Not sure why this is there but I think this is to allow for another thread reading the queue before you do...

Posts: 86
Joined: Wed Aug 22, 2012 9:57 pm
Location: Ottawa Canada

Re: Management of multiple tasks

Mon Oct 14, 2019 8:44 pm

I vote for MQTT

Then you can link disjoint pieces that can run as separate processes or even on separate machines. AND the pieces can be easier to debug. I just finished a IoT project with temperature sensors that uses MQTT and a common JSON structure. all the little bits were easy to build and test.

User avatar
Posts: 1432
Joined: Fri Aug 10, 2012 12:38 pm
Location: Cumbria, UK

Re: Management of multiple tasks

Mon Oct 14, 2019 9:23 pm

I would create one project. I have only ever needed one main thread and two additional threads at most even with complex projects.

Playing a video will probably run in its own instance of video player (I use omxplayer with the omxplayer-wrapper) so that is not an issue. Serial can be processed at the same time.

Posts: 1
Joined: Mon Oct 21, 2019 11:24 am

Re: Management of multiple tasks

Mon Oct 21, 2019 11:34 am

To manage multiple tasks usually, I use python along with C++. A comprehensive structure to stimulate working, monitoring and screen scraping robots are being activated. ... r-business

Return to “Other projects”