difference between semaphores and mutex?



difference between semaphores and mutex?..

Answer / 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

More C Interview Questions

In which header file is the null macro defined?

0 Answers  


Explain with the aid of an example why arrays of structures don’t provide an efficient representation when it comes to adding and deleting records internal to the array.

0 Answers  


Study the Following Points: a.One Cannot Take the address of a Bit Field b.bit fields cannot be arrayed c.Bit-Fields are machine Dependant d.Bit-fields cannot be declared as static 1. Which of the Following Statements are true w.r.t Bit- Fields A)a,b&c B)Only a & b C)Only c D)All

3 Answers   Accenture,


How can I set an array's size at run time?

9 Answers  


what are the 10 different models of writing an addition program in C language?

0 Answers  


main() { int l=6; switch(l) { default:l=l+2; case 4:l=4; case 5:l++; break; } printf("%d",l); }

1 Answers  


What are different storage class specifiers in c?

0 Answers  


4.weight conversion: Write a program that will read weight in pounds and convert it into grams.print both the original weight and the converted value.There are 454 grams in a pound.design and carry out a test plan for this program.

1 Answers   Wipro,


what is different between auto and local static? why should we use local static?

0 Answers  


How can you increase the size of a statically allocated array?

0 Answers   TISL,


wat is the output int main() { char s1[]="Hello"; char s2[]="Hello"; if(s1==s2) printf("Same"); else printf("Diff"); }

3 Answers  


What is pass by value in c?

0 Answers  


Categories