arkhipenko / TaskScheduler

Cooperative multitasking for Arduino, ESPx, STM32, nRF and other microcontrollers
http://playground.arduino.cc/Code/TaskScheduler
BSD 3-Clause "New" or "Revised" License
1.21k stars 221 forks source link

Set the core where a task execute #164

Closed sebarch closed 1 year ago

sebarch commented 1 year ago

Hi, it´s possible to set the core where a task is executed without using freertos? Thanks

arkhipenko commented 1 year ago

Hi.

No. TaskScheduler is a cooperative library, so it run in one thread in whatever task the scheduler and task objects are being called from. In fact, if you do use multiple rtos tasks, you should compile with thread protection.

Having said that, you can influence which core the rtos tasks is running on. For example and inspiration, please check the main sketch of the repo below.

https://github.com/arkhipenko/dnd/blob/master/esp32_dnd_rtos_mjpeg_multi/esp32_dnd_rtos_mjpeg_multi.ino

The method you'd want to look closely at is creareCoreTasks()

Notice how the video streaming task and TaskScheduler task are created pinned to different cores. Works like a charm.

Hope this helps.

Cheers, Anatoli

Sent from my mobile implant. Apologies for autocorrect.


From: sebarch @.> Sent: Friday, April 21, 2023 8:35:50 PM To: arkhipenko/TaskScheduler @.> Cc: Subscribed @.***> Subject: [arkhipenko/TaskScheduler] Set the core where a task execute (Issue #164)

Hi, it´s possible to set the core where a task is executed without using freertos? Thanks

— Reply to this email directly, view it on GitHubhttps://github.com/arkhipenko/TaskScheduler/issues/164, or unsubscribehttps://github.com/notifications/unsubscribe-auth/AACMMTLQFEZKT6G7PSVVRPLXCMRWNANCNFSM6AAAAAAXHOV73E. You are receiving this because you are subscribed to this thread.Message ID: @.***>

sebarch commented 1 year ago

Thanks for your quick replay