Is Event (ISR routine) thread-safe?

取消
显示结果 
显示  仅  | 搜索替代 
您的意思是: 
已解决

Is Event (ISR routine) thread-safe?

跳至解决方案
1,210 次查看
davidzhou
Contributor V

Hi,

I have a general threading question: (K60 MCU)

Let say SPI module is setup and enabled with interrupt. The interrput is serviced through module Event:

void SM1_OnBlockSent(LDD_TUserData *UserDataPtr) {

      //

     iSharedVariableCmdSentDone=1;

}

is the accessing of the iSharedVariableCmdSentDone thread-safe in the SM1_OnBlockSent() ?

Thank you,

David Zhou

标签 (1)
0 项奖励
回复
1 解答
962 次查看
TICS_Fiona
NXP Employee
NXP Employee

Hello David

The global variables in ISR routines generated by PE are not thread-safe. The ISRs are not reentrant functions. User needs to pay attention in his application code to protect the data. 

Best Regards

Fiona Kuang

Technical Information & Commercial Support

-----------------------------------------------------------------------------------------------------------------------

Note: If this post answers your question, please click the Mark Correct button. Thank you!

-----------------------------------------------------------------------------------------------------------------------

在原帖中查看解决方案

0 项奖励
回复
2 回复数
963 次查看
TICS_Fiona
NXP Employee
NXP Employee

Hello David

The global variables in ISR routines generated by PE are not thread-safe. The ISRs are not reentrant functions. User needs to pay attention in his application code to protect the data. 

Best Regards

Fiona Kuang

Technical Information & Commercial Support

-----------------------------------------------------------------------------------------------------------------------

Note: If this post answers your question, please click the Mark Correct button. Thank you!

-----------------------------------------------------------------------------------------------------------------------

0 项奖励
回复
962 次查看
davidzhou
Contributor V

Fiona,

Thank you for your answer.

David Zhou

0 项奖励
回复