delay_ticks() and yielding Topic is solved
-
- Active Member
- Posts: 34
- Joined: Sat Jul 08, 2023 5:15 am
delay_ticks() and yielding
Just confirming that delay_ticks() and its variants in timer.h, yield the task on which they're called?
View Solution
-
- New User
- Posts: 3
- Joined: Wed May 22, 2024 5:26 pm
Hi lukehatpadl,
delay_ticks uses a hardware timer and sets up an `in` on that timer after the specified number of ticks - therefore the core will block on that resource. As with other blocking operations, this core will no longer be scheduled until the timer unblocks. Other cores will continue operation as normal.
I am unsure whether this fully answers your question - using the term "yield the task" implies you're working in a more FreeRTOS-based system. Within a FreeRTOS task, raw timer accesses are discouraged as they sidestep the FreeRTOS task scheduler - instead, use vTaskDelay()/vTaskDelayUntil(), which will yield the FreeRTOS task and allow the task scheduler to execute another task in its stead.
delay_ticks uses a hardware timer and sets up an `in` on that timer after the specified number of ticks - therefore the core will block on that resource. As with other blocking operations, this core will no longer be scheduled until the timer unblocks. Other cores will continue operation as normal.
I am unsure whether this fully answers your question - using the term "yield the task" implies you're working in a more FreeRTOS-based system. Within a FreeRTOS task, raw timer accesses are discouraged as they sidestep the FreeRTOS task scheduler - instead, use vTaskDelay()/vTaskDelayUntil(), which will yield the FreeRTOS task and allow the task scheduler to execute another task in its stead.
-
- Active Member
- Posts: 34
- Joined: Sat Jul 08, 2023 5:15 am
Thanks, makes sense (I am using bare metal/XC, I just don't come from an embedded background).
-
- XCore Addict
- Posts: 225
- Joined: Mon Jan 08, 2018 4:14 pm
Hi Lukehatpadl
when you talk about yield and bare metal, it ring a bell. did you look at this lib now on GitHub?
https://www.xcore.com/viewtopic.php?p=40389#p40389
when you talk about yield and bare metal, it ring a bell. did you look at this lib now on GitHub?
https://www.xcore.com/viewtopic.php?p=40389#p40389