A Handy Thread Synchronization Object Chart

本文总结了不同内核对象在进程同步中的行为特性,包括进程、线程、作业、文件等对象的状态转换及其对等待线程的影响。此外还详细介绍了各种事件、信号量、互斥量及临界区等同步原语的工作机制。

摘要生成于 C知道 ,由 DeepSeek-R1 满血版支持, 前往体验 >

The following chart summarizes how the various kernel objects behave with respect to thread synchronization.

ObjectWhen NonsignaledWhen SignaledSuccessful Wait Side Effect
ProcessWhile process is still activeWhen process terminates (ExitProcess, TerminateProcess)None
ThreadWhile thread is still activeWhen thread terminates (ExitThread, TerminateThread)None
JobWhen job's time has not expiredWhen job time expiresNone
FileWhen I/O request is pendingWhen I/O request completesNone
Console inputNo input existsWhen input is availableNone
File change notificationsNo files have changedWhen file system detects changesResets notification
Auto-reset eventResetEvent, PulseEvent, or successful waitWhen SetEvent/PulseEvent is calledResets event
Manual-reset eventResetEvent or PulseEventWhen SetEvent/PulseEvent is calledNone
Auto-reset waitable timerCancelWaitableTimer or successful waitWhen time comes due (SetWaitableTimer)Resets timer
Manual-reset waitable timerCancelWaitableTimerWhen time comes due (SetWaitableTimer)None
SemaphoreSuccessful waitWhen count > 0 (ReleaseSemaphore)Decrements count by 1
MutexSuccessful waitWhen 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.

 
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值