Page 1 of 1

ESP32c3 - single threaded?

Posted: Wed Nov 22, 2023 10:24 am
by papadeltasierra
I believe the ESP32c3 only has a single core so two questions:
1. Does it still build using the ESP modified multi-core version of FreeRTOS or does it use the standard single-threaded version?
2. Do I need to worry about locking or can I be 100% sure that only one task at a time can be running and accessing data?
Thanks.

Re: ESP32c3 - single threaded?

Posted: Wed Nov 22, 2023 12:47 pm
by MicroController
papadeltasierra wrote:
Wed Nov 22, 2023 10:24 am
I believe the ESP32c3 only has a single core so two questions:
Yes, it's single-core.
1. Does it still build using the ESP modified multi-core version of FreeRTOS or does it use the standard single-threaded version?
Yes and no. It uses the same Espressif-FreeRTOS code, but built to run on a single core. That's not a "single-threaded" version though.
2. Do I need to worry about locking or can I be 100% sure that only one task at a time can be running and accessing data?
You do need to manage synchronization ("locking") because the OS is preemptive, which to an individual task is indistinguishable from true concurrency. Plus there are all the other interrupts.
However, when separating tasks' data and having them communicate via proper inter-task means (queues, semaphores,...) you won't need much 'manual' synchronization.

Re: ESP32c3 - single threaded?

Posted: Wed Nov 22, 2023 1:58 pm
by papadeltasierra
Thanks for that info. I was idly wondering "how might I pass a lot of data between tasks" and passing the pointer to a shared buffer would be one way, but would need some sort of protection in this case.

Re: ESP32c3 - single threaded?

Posted: Wed Nov 22, 2023 3:01 pm
by MicroController
Yes, a shared buffer is a valid use case which may require locking, or some other way of ensuring exclusive use of the buffer at any given time. Passing (pointers to) buffers back and forth between tasks ping-pong style via two queues can also do the trick, or using the IDF's ring buffer, for example.