[Logo] TCC discussion forum
  [Search] Search   [Recent Topics] Recent Topics   [Hottest Topics] Hottest Topics   [Top Downloads] Top Downloads   [Groups] Back to home page 
[Register] Register /  [Login] Login 


This forum is read only and new users cannot register, please ask all new questions either using GitHub discussions, or in Arduino forum tagging @davetcc.

semaphores and taskmanagerio RSS feed
Forum Index » IoAbstraction & TaskManagerIO
Author Message
werner


Joined: Feb 23, 2022
Messages: 4
Offline
Hi,
I use TaskmanagerIO with esp32.
How can I include semaphores with taskmanagerio ?
I have read something about xSemaphoreCreateBinary();
But is this the right way ?

best regards

Werner
davetcc


Joined: Jan 19, 2019
Messages: 686
Offline
You can use semaphores and mutexes with TaskManagerIO but you must be very careful that you don't lock the event processor as it is intentionally single-threaded. Locking or waiting for a resource that is not heavily contended is fine, but if the resource is often locked it may be better to do the locking asynchronously outside of task manager and post the results back in.

In the event that latency would be introduced, there are many ways in the past we have tried or thought of to move the work out of task manager:

* Using a second task manager as a queue on another thread where you just submit work to it for immediate execution using the execute method. This second instance of task manager acts like a queue and posts finished events back to the main task manager. This works really well for tasks that introduce a lot of latency.
* Using the circular buffer support in SimpleCollections library and have a thread constantly reading the buffer. https://github.com/davetcc/SimpleCollections
* Using an ESP32 task that posts the results into task manager.

EDIT - with any of the above solutions, you're opening yourself up to access from multiple threads, so the usual rules about atomicity and happens before - happens after apply. IE variable access must be atomic and critical blocks of code must be protected from multiple threads accessing at once.
 
Forum Index » IoAbstraction & TaskManagerIO
Go to:   
Mobile view
Powered by JForum 2.7.0 © 2020 JForum Team • Maintained by Andowson Chang and Ulf Dittmer

This site uses cookies to analyse traffic, serve ads by Google AdSense (non-personalized in EEA/UK), and to record consent. We also embed Twitter, Youtube and Disqus content on some pages, these companies have their own privacy policies.

Our privacy policy applies to all pages on our site

Should you need further guidance on how to proceed: External link for information about cookie management.