The following chart summarizes how the various kernel objects behave with respect to thread synchronization.
| Object | When Nonsignaled | When Signaled | Successful Wait Side Effect |
|---|---|---|---|
| Process | While process is still active | When process terminates (ExitProcess, TerminateProcess) | None |
| Thread | While thread is still active | When thread terminates (ExitThread, TerminateThread) | None |
| Job | When job's time has not expired | When job time expires | None |
| File | When I/O request is pending | When I/O request completes | None |
| Console input | No input exists | When input is available | None |
| File change notifications | No files have changed | When file system detects changes | Resets notification |
| Auto-reset event | ResetEvent, PulseEvent, or successful wait | When SetEvent/PulseEvent is called | Resets event |
| Manual-reset event | ResetEvent or PulseEvent | When SetEvent/PulseEvent is called | None |
| Auto-reset waitable timer | CancelWaitableTimer or successful wait | When time comes due (SetWaitableTimer) | Resets timer |
| Manual-reset waitable timer | CancelWaitableTimer | When time comes due (SetWaitableTimer) | None |
| Semaphore | Successful wait | When count > 0 (ReleaseSemaphore) | Decrements count by 1 |
| Mutex | Successful wait | When unowned by a thread (ReleaseMutex) | Gives ownership to thread |
| Critical section (user-mode) | Successful wait ((Try)EnterCriticalSection) | When unowned by a thread (LeaveCriticalSection) | Gives ownership to thread |
Interlocked (user-mode) functions never cause a thread to be unschedulable; they alter a value and return immediately.
本文总结了不同内核对象在进程同步中的行为特性,包括进程、线程、作业、文件等对象的状态转换及其对等待线程的影响。此外还详细介绍了各种事件、信号量、互斥量及临界区等同步原语的工作机制。
1622

被折叠的 条评论
为什么被折叠?



