Click here to Skip to main content
15,896,201 members
Please Sign up or sign in to vote.
0.00/5 (No votes)
See more:
Hi Currently I am reading some Multithreading issues. There is a common description
of the 'Synchronization Objects' that except Critical Section all other objects are waitable.

This terminology is creating confusion as
1. All the threads who want a resource get blocked on CS and wait till the CS is released.
2. Same is the situation with all other synchronization objects as well.

Still why CS is called as not waitable
and other as true waitable objects.

regards
kanade
Posted
Updated 13-May-11 5:54am
v3

1 solution

This is some terminology in some documentation I cannot be responsible for.

I just took a look at some object and think I can see the difference. To my taste, it is really minor. There is one simplification which makes Critical Section different. It can be considered as a lightweight version of Mutex. It has a bit simplified interface and can only be used for synchronization between threads of the same process, not between threads of different processes.

First of all, the 'Synchronization Objects' primitives bring the thread in a special wait state. OS switches out the thread entering the Critical Section or waiting for other Synchronization Objects and doesn't schedule it back to execution until it is waked up by a certain interrupt condition. In this way the thread consumes strictly zero CPU time until it is awakened.

In case of Critical Section, the thread is blocked when some other thread had already entered the same Critical Section instance and is awakened when the other thread leaves this Critical Section instance.

For the very similar Mutex and many other Synchronization Objects there is another special wake-up condition: a timeout. This is the difference. The Synchronization Objects which have an (optional or additional) blocking method with a timeout parameter are called Waitable.

This is the answer. Your only problem is that this term is not really self-descriptive but somewhat misleading. I personally try to avoid it.

—SA
 
Share this answer
 
v3
Comments
Manfred Rudolf Bihy 13-May-11 13:01pm    
Did some none technical edits.
I hope you don't mind. :)
Sergey Alexandrovich Kryukov 13-May-11 18:45pm    
I trust you when you do it. Thank you very much for your help.
--SA

This content, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)



CodeProject, 20 Bay Street, 11th Floor Toronto, Ontario, Canada M5J 2N8 +1 (416) 849-8900