difference between semaphores and mutex?

Answer Posted / selvakumar

"Mutexes are typically used to serialise access to a
section of re-entrant code that cannot be executed
concurrently by more than one thread. A mutex object only
allows one thread into a controlled section, forcing other
threads which attempt to gain access to that section to
wait until the first thread has exited from that section."

"A semaphore restricts the number of simultaneous users of
a shared resource up to a maximum number. Threads can
request access to the resource (decrementing the
semaphore), and can signal that they have finished using
the resource (incrementing the semaphore)."

Is This Answer Correct ?    15 Yes 2 No



Post New Answer       View All Answers


Please Help Members By Posting Answers For Below Questions

What is cohesion and coupling in c?

785


Explain why C language is procedural?

956


What is the size of enum in bytes?

781


Explain the difference between malloc() and calloc() function?

797


Why C language is a procedural language?

793


A collection of functions,calls,subroutines or other data a) library b) header files c) set of files d) textfiles

887


One of the Institutes contains 5 student groups. Every group contains 4 students. Institute wants to store student group’s details in array. Group should contain group member’s details (name and registration number and age), project name, and mark of the group.

2400


How can I run c program?

918


Write the program that calculates and prints the average of several integers. Assume that the last value read is sentinel 9999.

3379


Are there namespaces in c?

774


How do you write a program which produces its own source code as output?

825


What is the default value of local and global variables in c?

750


Find duplicates in a file containing 6 digit number (like uid) in O (n) time.

2946


What are the standard predefined macros?

816


What is a c token and types of c tokens?

810