Page 1 of 1
Why is chThdGetSelfX() X-class?
Posted: Thu Oct 27, 2016 6:55 am
by awygle
Why are calls like chThdGetSelfX() and chThdGetPriorityX() X-class APIs? I don't understand how they would have a well-defined meaning in an ISR context. Is it because there isn't a class defined for "you can call this outside lock zones but not in ISRs"? Or am I just confused and they actually would have a meaning in an ISR?
Re: Why is chThdGetSelfX() X-class?
Posted: Thu Oct 27, 2016 7:11 am
by Giovanni
Hi,
There isn't class "everywhere except ISRs".
Those function do not have much use in ISR context because the current thread is random, the functions are X-class because you can call them inside or outside critical zones. Anyway, those functions can be called from ISR, for example to see which thread has been preempted by the ISR for statistics.
The X means that it can be done, it is not an assessment of usefulness.
Giovanni
Re: Why is chThdGetSelfX() X-class?
Posted: Thu Oct 27, 2016 7:22 am
by awygle
Giovanni wrote:Anyway, those functions can be called from ISR, for example to see which thread has been preempted by the ISR for statistics.
This is an excellent point that I hadn't considered. I was just thinking that perhaps I was wrong, or that if they had no use (and in fact were dangerous) in ISRs that perhaps they should be changed, but this is a totally valid use case. Thank you.