In the last articles we saw how to synchronize two threads using critical section and mutex. They allow both the threads to execute at the same time. But only one thread can access the blocking object at a time. However, sometimes we may wish to write two threads where one thread should not get executed [...]
Full Story »Thread Synchronization: Using Events Signaling
Thread Synchronization : Using Mutex Objects
Download source code for this project here Thread Synchronization Using Mutex
The word mutex comes from mutually and exclusive. Mutexe is used to gain exclusive access to a resource mutually shared by two or more threads. Unlike critical sections, mutexes can be used to synchronize threads running in the same process or in different processes. There [...]
Thread Synchronization : Using Critical Section
Download source code for this project from here Using Critical Section
Software development is a team effort. Unless team members cooperate with one another, synchronize their work with the rest of the team, the team can’t go far. Similarly if in a program there are several threads running, unless their activities are synchronized with one another [...]
What is Multithreading?
Multi-Threading in Windows
there are two ways to program with multiple threads: use the Microsoft Foundation Class (MFC) library or the C run-time library and the Win32 API.
What is threading ?
A thread is basically a path of execution through a program. It is also the [...]
Threading Questions and Answers
37) What is the difference between process and thread?
Ans: Process is a program in execution whereas thread is a separate path of execution in a program.
38) What is multithreading and what are the methods for inter-thread communication and what is the class in [...]
Multithreading and Synchronization in Win32 applications
Synchronization – Overview
The concurrent execution of threads and processes in
Win32 is achieved by synchronization mechanisms.
Following methods/objects are used to achieve synchronization
Critical Section
– single process;
– non kernel object
Mutexes
Mutually Exclusive
Critical Section + Multi Processes
Semaphores
Semaphores – [...]
What is a Message Loop ?
while(GetMessage(&Msg, NULL, 0, 0) > 0)
{
TranslateMessage(&Msg);
DispatchMessage(&Msg);
}
1. The message loop calls GetMessage(), which looks in your message queue. If the message queue is empty your program basically stops and waits for one (it Blocks).
2. When an event occures causing a message to be added to the queue (for example the system registers a mouse [...]