adplus-dvertising
frame-decoration

Question

What is the purpose of semaphores in multithreaded programming?

a.

To allow multiple threads to own a semaphore simultaneously

b.

To ensure data validity at all times

c.

To synchronize multiple threads within the same program

d.

To limit the number of threads that can access a resource at any given moment

Posted under Reverse Engineering

Answer: (d).To limit the number of threads that can access a resource at any given moment Explanation:A semaphore is like a mutex with a user-defined counter that defines how many simultaneous owners are allowed on it. Once that maximum number is exceeded, a thread that requests ownership of the semaphore will enter a wait state until one of the threads releases the semaphore.

Engage with the Community - Add Your Comment

Confused About the Answer? Ask for Details Here.

Know the Explanation? Add it Here.

Q. What is the purpose of semaphores in multithreaded programming?