NCS version 1.9.1
nRF52840 DK
I have a task that waits on a semaphore with a timeout. Sometimes the task gets stuck in the k_sem_take() call, even though there is a timeout. Even giving the semaphore fails to make the k_sem_take() call return.
Is this a bug? Is there a workaround? The whole point of the time out is for the while(1) loop body to execute at least periodically.
// Semaphores
struct k_sem sem_mysem;
void main(void)
{
k_sem_init(&sem_mysem, 0, 10);
tid_mytask = k_thread_create(&kthread_data, stack_mytask, K_THREAD_STACK_SIZEOF(stack_mytask), my_task, NULL, NULL, NULL, KTHREAD_MYTASK_PRIORITY, 0, K_NO_WAIT);
}
void my_task( void *p1, void *p2, void *p3)
{
// Initialize some stuff
while (1)
{
// Wait 200 msec, or semaphore give from another task
k_sem_take(&sem_mysem, K_MSEC(200));
// do some stuff
}
}
Thanks,
Mary