Why is chThdGetSelfX() X-class?

ChibiOS public support forum for all topics not covered by a specific support forum.

Moderators: RoccoMarco, lbednarz, tfAteba

Post Reply
awygle
Posts: 32
Joined: Sun Apr 03, 2016 8:39 pm
Has thanked: 6 times
Been thanked: 4 times

Why is chThdGetSelfX() X-class?

Post 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?
User avatar
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?

Post 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
awygle
Posts: 32
Joined: Sun Apr 03, 2016 8:39 pm
Has thanked: 6 times
Been thanked: 4 times

Re: Why is chThdGetSelfX() X-class?

Post 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.
Post Reply