delay_ticks() and yielding Topic is solved

If you have a simple question and just want an answer.
User avatar
lukehatpadl
Active Member
Posts: 34
Joined: Sat Jul 08, 2023 5:15 am

delay_ticks() and yielding

Post by lukehatpadl »

Just confirming that delay_ticks() and its variants in timer.h, yield the task on which they're called?
View Solution
ACascarino - XMOS
New User
Posts: 3
Joined: Wed May 22, 2024 5:26 pm

Post by ACascarino - XMOS »

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.
User avatar
lukehatpadl
Active Member
Posts: 34
Joined: Sat Jul 08, 2023 5:15 am

Post by lukehatpadl »

Thanks, makes sense (I am using bare metal/XC, I just don't come from an embedded background).
User avatar
fabriceo
XCore Addict
Posts: 226
Joined: Mon Jan 08, 2018 4:14 pm

Post by fabriceo »

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