Set - 3

Question 6 :

What is signaled and non signaled state?

Answer :

An event is in signaled state means that it has the capacity to release the threads waiting for this event to be signaled. An event is in non signaled state means that it will not release any thread that is waiting for this particular event.example in our project: when user clicks the image application icon double simultaneously. Two image application windows were created. so PAIG created an event and set it to non-signaled state. Then the image application will reset the event to signaled state, after this all the threads are released.


Question 7 :

APIs for creating event and set and reset the events

Answer :

CreateEvent- to create the event
OpenEvent - to open already created event
SetEvent - to set the event signaled state
RestEvent - To set the Event To non-Signaled State


Question 8 :

What is Mutex Object and why it is used?

Answer :

A mutex object is a synchronization object whose state is set to signaled when it is not owned by any thread, and non-signaled when it is owned. For example, to prevent two threads from writing to shared memory at the same time, each thread waits for ownership of a mutex object before executing the code that accesses the memory. After writing to the shared memory, the thread releases the mutex object.


Question 9 :

How do I create a Mutex?

Answer :

A thread uses the CreateMutex function to create a mutex object. The creating thread can request immediate ownership of the mutex object and can also specify a name for the mutex object


Question 10 :

How do other threads own the mutex?

Answer :

Threads in other processes can open a handle to an existing named mutex object by specifying its name in a call to theOpenMutex - function. Any thread with a handle to a mutex object can use one of the wait functions to request ownership of the mutex object. If the mutex object is owned by another thread, the wait function blocks the requesting thread until the owning thread releases the mutex object using theReleaseMutex - function.