using mutex or manipulation a queue in an interrupt service routine

Tip / Sign in to post questions, reply, level up, and achieve exciting badges. Know more

cross mob
MaFa_974161
Level 5
Level 5
100 sign-ins 50 replies posted 50 questions asked

Hello, 

I've bought CYW943907AEVAL1F board.

 

I develop a firmware that manipulate a mutex (wiced_rtos_lock_mutex) and manipulate a queue (wiced_rtos_push_to_queue) in a ISR (interrupt service routine) but each API calls get me errors:

 

wiced_rtos_lock_mutex returns 4 (WICED_ERROR)

wiced_rtos_push_to_queue returns 1032 (WICED_QUEUE_ERROR)

 

I suspect that I can't manipulate mutex or queue in a ISR (interrupt service routine)  ...

can you confirm this ?

 

Thankyou.

 

 

0 Likes
1 Solution
Félix_T
Level 5
Level 5
10 sign-ins First comment on blog 50 replies posted

Locking a mutex is usually not allowed from and ISR, because it can block. If your ISR blocks, then your system would effectively lock up, and never be able to return to the threads.

As far as pushing to a a queue from an ISR, you can do it, BUT, it depends on how the wiced_rtos_push_to_queue call is implemented. If the call to the RTOS queue function is made with a timeout value set to anything other than 'no timeout' then, you cannot use wiced_rtos_push_to_queue in an ISR, because allowing a timeout could possibly block.

View solution in original post

1 Reply
Félix_T
Level 5
Level 5
10 sign-ins First comment on blog 50 replies posted

Locking a mutex is usually not allowed from and ISR, because it can block. If your ISR blocks, then your system would effectively lock up, and never be able to return to the threads.

As far as pushing to a a queue from an ISR, you can do it, BUT, it depends on how the wiced_rtos_push_to_queue call is implemented. If the call to the RTOS queue function is made with a timeout value set to anything other than 'no timeout' then, you cannot use wiced_rtos_push_to_queue in an ISR, because allowing a timeout could possibly block.