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
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 |
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 |
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 |
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 |
What are the different types of comments allowed in c++?
How did c++ start?
Is main a class in c++?
What are the conditions that have to be met for a condition to be an invariant of the class?
What is c++ coding?
What return value must conversion operators have in their declaration?
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
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)
Why ctype h is used in c++?
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?
Is c++ map a hash table?
Compare compile time polymorphism and Runtime polymorphism