Welcome to graduate2professional.blogspot.com

Monday, June 1, 2009

FAQs on semaphore/Mutex inVXworks

Q: What are the different types of semaphores in vxworks? Which is the fastest?

A: VxWorks supports three types of semaphores. Binary, mutual exclusion, and counting semaphores. Binary is the fastest semaphore.


Q: When will you use binary semaphore ?

A: Binary semaphores are used for basic task synchronization and communication.


Q: When will you use mutual exclusion semaphore?

A: Mutual exclusion semaphores are sophisticated binary semaphores that are used to address the issues relating to task priority inversion and semaphore deletion in a multitasking environment.


Q: When will you use Counting semaphore?

A: Counting semaphores maintain a count of the number of times a resource is given. This is useful when an action is required for each event occurrence. For example if you have ten buffers, and multiple tasks can grab and release the buffers, then you want to limit the access to this buffer pool using a counting semaphore.


Q: What is the difference between Mutex and binary semaphore?

A: The differences are:

1) Mutex can be used only for mutual exclusion, while binary can be used of mutual exclusion as well as synchronisation.

2) Mutex can be given only by the task that took it.

3) Mutex cannot be given from an ISR.4) Mutual-exclusion semaphores can be taken recursively. This means that the semaphore can be taken more than once by the task that holds it before finally being released.5) Mutex provides a options for making the task that took it as DELETE_SAFE. This means, that the task cannot be deleted when it holds mutex.

No comments:

Post a Comment