of Synchronization and Resource Sharing
The range of synchronization objects provided by Windows is very similar to those spec-ified in POSIX:
n Mutex locks ensure that only one thread has access to a resource at a time. If the lock is held by another thread, the thread attempting to acquire the lock will sleep until the lock is released. A timeout can also be specified so that lock acquisition will fail if the lock does not become available within the specified interval. If mul-tiple threads are waiting for the lock, the order in which the waiting threads will acquire the mutex is not guaranteed. Mutexes can be shared between processes.
n Critical sections are similar to mutex locks. The difference is that critical sections cannot be shared between processes; consequently, their performance overhead is lower. Critical sections also have a different interface from that provided by mutex locks. Critical sections do not take a timeout value but do have an interface that allows the calling thread to try to enter the critical section. If this fails, the call immediately returns, enabling the thread to continue execution. They also have the facility of spinning for a number of iterations before the thread goes to sleep in the situation where the thread is unable to enter the critical section.
n Slim reader/writer locks provide support for the situation where there are multiple threads that read shared data, but on rare occasions the shared data needs to be written. Data that is being read can be simultaneously accessed by multiple threads without concern for problems with corruption of the data being shared. However, only a single thread can have access to update the data at any one time, and other threads cannot access that data during the write operation. This is to prevent threads from reading incomplete or corrupted data that is in the process of being written. Slim reader/writer locks cannot be shared across processes.
Semaphores provide a means of restricting access to a finite set of resources or of signaling that a resource is available. These are essentially the same as the sema phores provided by POSIX. As is the case with mutex locks, semaphores can be shared across processes.
n Condition variables enable a thread to be woken when a condition becomes true. Condition variables cannot be shared between processes.
n Events are a method of signaling within or between processes. They provide similar functionality to the signaling capability of semaphores.
Copyright © 2018-2020 BrainKart.com; All Rights Reserved. Developed by Therithal info, Chennai.