Difference between semaphore and event

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

Difference between semaphore and event

ソリューションへジャンプ
2,864件の閲覧回数
admin
Specialist II

What is the difference between semaphore and event?

Is it advisable to replace event with semaphore and vise versa?

0 件の賞賛
返信
1 解決策
1,515件の閲覧回数
DavidS
NXP Employee
NXP Employee

Hi n3prakash,

Good RTOS definitions and understanding is in the FSLMQX/doc/mqx/mqxug.pdf chapter #2.
In general an event is good to indicate an interrupt has occured and you want to notify one or more tasks that the interrupt has occured.
Semaphore good for limiting the number of tasks that can access a specific resource.  Example might be you only want two task to be able to output data on a specific UART.  If a third tasks tried to output data it would block until a semaphore became available.  A mutext is a special case of semiphore where only one task can access a resource.  Example would be a task data logging to a file where you cannot have more than one task accessing the same file.
Hope this helps.
Regards,
David

元の投稿で解決策を見る

0 件の賞賛
返信
1 返信
1,516件の閲覧回数
DavidS
NXP Employee
NXP Employee

Hi n3prakash,

Good RTOS definitions and understanding is in the FSLMQX/doc/mqx/mqxug.pdf chapter #2.
In general an event is good to indicate an interrupt has occured and you want to notify one or more tasks that the interrupt has occured.
Semaphore good for limiting the number of tasks that can access a specific resource.  Example might be you only want two task to be able to output data on a specific UART.  If a third tasks tried to output data it would block until a semaphore became available.  A mutext is a special case of semiphore where only one task can access a resource.  Example would be a task data logging to a file where you cannot have more than one task accessing the same file.
Hope this helps.
Regards,
David
0 件の賞賛
返信