ThreadX to FreeRTOS porting

I am in process to port operating system from ThreadX to FreeRTOS on my current project.
Its kinda weird question, but wondering if anyone have come across it or have any idea on it.

In ThreadX prior calling any function a validity request check is performed via below ->
(_tx_thread_system_state) || (_tx_thread_current_ptr == &_tx_timer_thread))

My understanding of above statement is that its trying to determine if the function is been called by thread or system context. I found similar implementation in one of the link.

Is it possible to determine if the caller is a Task or system context in FreeRTOS ? if so how could I implement that ?

Thank you in advance.


When you say system context, do you mean ISR? If so, it depends on your port. For Cortex-M, you can use xPortIsInsideInterrupt function -

Where do you want to put this check?


Hi Gaurav,

Thanks for your feedback. I will explore this function.

I want to use this check in application to determine if the function needs to be guarded by mutex or not. Basically my current code based on threadX uses above mentioned condition to identify if caller function is a thread or not.