I recently read that the critical sections in Windows doesn't go into the kernel unless they have a contention. Unfortunately, I didn't understand quite correctly what does it actually mean. What this "contention" is?
Asked
Active
Viewed 59 times
0
-
If thread A already has the critical section locked, and thread B tries to lock it as well, you have a contention and thread B has to wait. – Jonathan Potter Nov 11 '15 at 08:48
-
@Jonathan Potter So, critical sections are only fast when they are not already locked by another thread? – FrozenHeart Nov 11 '15 at 08:53
-
If they're blocked by another thread it's not a question of them being "not fast"; they have to wait until the other thread unlocks the CS. Which takes as long as it takes. – Jonathan Potter Nov 11 '15 at 09:30
-
@Jonathan Potter I mean that critical sections go to the kernel only if this critical section was already locked, otherwise it just increments the "lock counter". Am I right? – FrozenHeart Nov 11 '15 at 09:38
-
2I believe that's how it works, yes. – Jonathan Potter Nov 11 '15 at 10:23