Why is chThdGetSelfX() X-class?
Moderators: RoccoMarco, lbednarz, tfAteba
Why is chThdGetSelfX() X-class?
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?
- Giovanni
- Site Admin
- Posts: 14891
- Joined: Wed May 27, 2009 8:48 am
- Has thanked: 1202 times
- Been thanked: 996 times
Re: Why is chThdGetSelfX() X-class?
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
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?
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.