Can we get a timeout on lock_acquire()

Technical questions regarding the XTC tools and programming with XMOS.
Post Reply
erlingrj
Member++
Posts: 16
Joined: Tue Aug 10, 2021 1:21 pm

Can we get a timeout on lock_acquire()

Post by erlingrj »

Hi.

According to the documentation of <xcore/lock.h> (https://www.xmos.ai/documentation/XM-01 ... ire6lock_t) it seems that there is no way to wait for a lock or another event in a select. I know that there are ways of configuring interrupts and that it should be possible to have the logical core be interrupted by a timer event. But can I abort the call to lock_aquire() from the ISR?


User avatar
akp
XCore Expert
Posts: 578
Joined: Thu Nov 26, 2015 11:47 pm

Post by akp »

lock_acquire() for a hardware lock uses an "in" instruction. There is no way to put a timeout on a lock that I can see from the ISA. The "in" instruction won't complete until the core can take the lock.

Interrupts won't help, because per the ISA "interrupts are taken between instructions". That means the "in" instruction would have to complete before the ISR is executed.

This applies to both XS2 and XS3 architectures.
erlingrj
Member++
Posts: 16
Joined: Tue Aug 10, 2021 1:21 pm

Post by erlingrj »

Thanks for your insightful reply. I guess I have to resort to a busy-wait on the lock.
Post Reply