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

What are the different types of comments allowed in c++?

0 Answers  


How did c++ start?

0 Answers  


Is main a class in c++?

0 Answers  


What are the conditions that have to be met for a condition to be an invariant of the class?

1 Answers  


What is c++ coding?

0 Answers  






What return value must conversion operators have in their declaration?

0 Answers  


Write a program which is required to process the time of a clock in hours and minutes, entered from the keyboard. With this program, there are two requirements for any data entered by a user: 1. The data must be of the correct type (in this case, two ints). 2. The data must be in the correct range: this means that, for the minutes, negative numbers and any number above 59 must be rejected; for the hours, negative numbers and any number above 23 must be rejected. Output error message for invalid data input. Output the time one and a half hour after the time input. i.e. Hour: 22 Min: 32 One and a half hour after 22:32 is 00:02

0 Answers  


Write a single instruction that will store an EVEN random integer between 54 and 212 inclusive in the variable myran. (NOTE only generate EVEN random numbers)

0 Answers  


Why ctype h is used in c++?

0 Answers  


There is a magic square matrix in such a way that sum of a column or a row are same like 3 5 2 4 3 3 3 2 5 sum of each column and row is 10. you have to check that matrix is magic matrix or not?

1 Answers   TCS,


Is c++ map a hash table?

0 Answers  


Compare compile time polymorphism and Runtime polymorphism

1 Answers  


Categories