Windows Thread Synchronization 1

 

 

 

Introduction

 

There are a variety of ways to coordinate multiple threads of execution in multithreading environment. The functions described in this section provide mechanisms that threads can use to synchronize access to a shared and limited resource. Let say in multithreaded environment, a process has 4 threads which need to access and manipulate a single shared, global variable X. Threads need authority before they can interact with X. Let say that everyone needs to access X to complete their tasks, but there is only one X. Assuming from the following Figure, Thread 5 and Thread 6 already finished accessing X. If a thread wants to use X, it must first becomes the authority of X. It must also agree with all the threads that it has the right to use X. While this thread is using X, all other threads must wait/sleep for their turn. If multiple threads all want to access and use X at the same time, there must be a mechanism to ensure that only one thread can access X at a time.

 

Windows Thread Synchronization issue: The shared, limited computer resource

 

 

The Windows thread synchronization issue and problem

 

This kind of activity is called locking for threads. There are a lot of ways to support how to use the shared resources such as critical sections, mutexes and semaphores, events, and atomic operations. To synchronize access to a resource, we can use one of the synchronization objects in one of the wait functions. The state of a synchronization object is either signaled or non-signaled. The wait functions allow a thread to block its own execution until a specified non-signaled object is set to the signaled state.

 

 

 

< Thread Synchronization Programming | Win32 Programming | Thread Synchronization 2 >