1.

What is Semaphore?(a) Grant more than one thread access to a shared resource at the same time(b) Useful when a collection of resources is being synchronized(c) Make use of a counter to control access to a shared resource(d) All of the mentionedI had been asked this question in an international level competition.Question is taken from Multithreaded Programming topic in division Reflections, Multithreaded Programming, Collection Classes and Mathematical Functions of C#

Answer»

Correct answer is (d) All of the mentioned

To explain: A semaphore is SIMILAR to a mutex except that it can grant more than one thread access to a shared RESOURCE at the same time. Thus, the semaphore is useful when a collection of resources is being SYNCHRONIZED. A semaphore controls access to a shared resource through the USE of a counter. If the counter is greater than zero, then access is allowed. If it is zero, access is DENIED.



Discussion

No Comment Found

Related InterviewSolutions