Is there anything like critical section within SDK?

キャンセル
次の結果を表示 
表示  限定  | 次の代わりに検索 
もしかして: 

Is there anything like critical section within SDK?

ソリューションへジャンプ
1,659件の閲覧回数
tonymakkiel
Contributor III


Hi,

        Is there something like windows critical section within SDK 2.0 (or a mutex/semaphore will do). I am not using any RTOS. Basically there is a function which I do not want the system to interrupt, to service anything else. I am using SDK 2.0 for KL43.

 

The problem is the function shares a variable with uart callback function. So if there is a uart callback while the function is being services, the call back function changes the value and if my function is half way through processing based on initial value, when it resumes it goes crazy!

 

Many Thanks,

Tony

ラベル(1)
タグ(2)
0 件の賞賛
返信
1 解決策
1,454件の閲覧回数
bobpaddock
Senior Contributor III

atomic.h attached gives the needed code.

    ATOMIC_BLOCK( ATOMIC_RESTORESTATE )

    {

      // protected stuff.

    }

元の投稿で解決策を見る

0 件の賞賛
返信
2 返答(返信)
1,455件の閲覧回数
bobpaddock
Senior Contributor III

atomic.h attached gives the needed code.

    ATOMIC_BLOCK( ATOMIC_RESTORESTATE )

    {

      // protected stuff.

    }

0 件の賞賛
返信
1,454件の閲覧回数
tonymakkiel
Contributor III

Thank you very much :smileyhappy:.

0 件の賞賛
返信