priority order violation when calling chSysUnlock from virtual timer callback

Discussions and support about ChibiOS/RT, the free embedded RTOS.
sidbh
Posts: 8
Joined: Sat Sep 02, 2017 2:03 pm
Been thanked: 2 times

priority order violation when calling chSysUnlock from virtual timer callback

Postby sidbh » Tue Oct 10, 2017 8:04 am

Hi,
I am trying to do a mutex lock inside the virtual timer callback set using chVTSet method. But I see that from the chSysUnlock i.e. called from while being inside the callback for mutex lock leads to debug error, Priority order violation. the value of ch.rlist.current is idle_thread context and the value of next is the thread which I created from which the chVTSet was called and has priority of 181. I am trying to understand is it illegal to do locks inside virtual timer callbacks, which doesn't seem so from example codes as you are calling function which do critical sections from the callbacks. So why I am having this issue.

Regards,
Siddharth

User avatar
Giovanni
Site Admin
Posts: 14444
Joined: Wed May 27, 2009 8:48 am
Location: Salerno, Italy
Has thanked: 1074 times
Been thanked: 921 times
Contact:

Re: priority order violation when calling chSysUnlock from virtual timer callback

Postby Giovanni » Tue Oct 10, 2017 9:02 am

Hi,

It is illegal to do in callbacks/ISRs anything that can change the state of the current thread. In general, from callbacks/ISRs you can only call I-Class functions, those whose name is ended by "I".

The state checker, which you should enable, detects this kind of violations.

Giovanni


Return to “ChibiOS/RT”

Who is online

Users browsing this forum: No registered users and 13 guests