What is a mutex and a critical section.Whats difference
between them?How do each of them work?

Answers were Sorted based on User's Feedback



What is a mutex and a critical section.Whats difference between them?How do each of them work?..

Answer / prasenjit roy

Mutex is a locking object ( like a flag ) for avoiding the
simultaneous use of a common resource. It is also used to
lock the critical section.

Ctitical Section :: is a block of code which should run
atomically ie. there should be no contact switching while
this block executes and once the block starts it should
finish without any interruption.

Is This Answer Correct ?    10 Yes 0 No

What is a mutex and a critical section.Whats difference between them?How do each of them work?..

Answer / achal ubbott

Above answers are correct.now I tell why?
1. Critical Section Object works faster because Critical
section is a user object and is specific to a process.
Where as a Mutex is a kernel object and so many
processes running over the kernel can lock or
unlock/release it. So it is a bit heavier than Critical
Section and thus slow.
2. When control enters the critical section the interrupts
(from various devices like FEC, UART etc. ) to the CPU core
are disabled

Is This Answer Correct ?    7 Yes 0 No

What is a mutex and a critical section.Whats difference between them?How do each of them work?..

Answer / edward

Both of them are synchronization objects .Critical section
used for snychronization of threads in a same
process.Mutexs used for sybchronizating a threads in diff
process

Is This Answer Correct ?    7 Yes 2 No

What is a mutex and a critical section.Whats difference between them?How do each of them work?..

Answer / vikas

Both of them are synchronization objects.
Critical sections are used for intraprocess synchronization
while mutexes are required for interprocess
synchronization. The latter is much heavier in terms of
resources consumed.

Vikas
http://www.cppquestions.com

Is This Answer Correct ?    7 Yes 3 No

Post New Answer

More C++ General Interview Questions

How many types of classes are there in c++?

0 Answers  


Can circle be called an ellipse?

0 Answers  


True or false, if you keep incrementing a variable, it will become negative a) True b) False c) It depends

0 Answers  


What is the syntax for a for loop?

0 Answers  


What are the two shift operators and what are their functions?

0 Answers  






Explain function overloading and operator overloading.

0 Answers  


What size is allocated to the union variable?

0 Answers  


What do you mean by volatile and mutable keywords used in c++?

0 Answers  


What is meant by const_cast?

0 Answers  


Is c++ a float?

0 Answers  


What is meant by the term name mangling in c++?

0 Answers  


What are class and object in C++?

1 Answers  


Categories