The following kernel objects can be in a signaled or nonsignaled state:
Processes Threads Jobs Files Console input File change notifications
Events Waitable timers Semaphores Mutexes
The rules for a semaphore are as follows:
If the current resource count is greater than 0, the semaphore is signaled.
If the current resource count is 0, the semaphore is nonsignaled.
The system never allows the current resource count to be negative.
The current resource count can never be greater than the maximum resource count.
Mutex objects are different from all other kernel objects because they have a notion of "thread ownership."
Characteristic Mutex Critical Section
Performance Slow Fast
Can be used across process boundaries Yes No
Declaration HANDLE hmtx; CRITICAL_SECTION cs;
Initialization hmtx= CreateMutex(NULL, FALSE, NULL); InitializeCriticalSection(&cs);
Cleanup CloseHandle(hmtx); DeleteCriticalSection(&cs);
Infinite wait WaitForSingleObject(hmtx, INFINITE); EnterCriticalSection(&cs);
0 wait WaitForSingleObject(hmtx, 0); TryEnterCriticalSection(&cs);
Arbitrary wait WaitForSingleObject(hmtx, dwMilliseconds); Not possible
Release ReleaseMutex(hmtx); LeaveCriticalSection(&cs);
Can be waited on with other kernel objects Yes No