Saturday, July 20, 2013

μITRON based RTOS Questions and Answers

①When there is a case where anyone of Semaphore or Event flag can be used, which one will you use?

I will use Semaphore. Because, it is lightweight and the processing speed is faster than event flags.

②Why Semaphore is faster than the event flags?

Reason ①: Semaphore maintains the homogeneous resources. So, it is just based on incrementing and decrementing count of resources. But, in event flags, each task has different waiting conditions. So, it's internal processing needs to check current bit pattern and whether it satisfies the requested bit pattern and it is little more complex than the semaphore.
 
Reason ②: The number of arguments in event flag APIs are more than that of semaphore APIs. This will have performance penalty and the event flag implementation needs to save all the arguments in the task context in case of the task going to wait for the event. So, it's processing is time consuming and consumes more memory than the semaphore.

Post your questions if you have. Let's try to find answeres!

No comments: