sys: wait groups and notify implementation

This commit is contained in:
Bill Zissimopoulos
2020-10-09 12:40:49 -07:00
parent a004e4be10
commit 3687df53c6
4 changed files with 104 additions and 5 deletions

View File

@ -652,6 +652,28 @@ VOID FspIrpHookReset(PIRP Irp);
PVOID FspIrpHookContext(PVOID Context);
NTSTATUS FspIrpHookNext(PDEVICE_OBJECT DeviceObject, PIRP Irp, PVOID Context);
/* utility: wait groups
*
* A Wait Group is a synchronization primitive that encapsulates a counter.
* A Wait Group is considered signaled when the counter is 0 and non-signaled
* when the counter is non-0. (Wait Group functionality is similar to Golang's
* sync.WaitGroup.)
*
* Wait Groups must always be allocated in non-paged storage.
*/
typedef struct
{
KEVENT Event;
LONG Count;
KSPIN_LOCK SpinLock;
} FSP_WGROUP;
VOID FspWgroupInitialize(FSP_WGROUP *Wgroup);
VOID FspWgroupIncrement(FSP_WGROUP *Wgroup);
VOID FspWgroupDecrement(FSP_WGROUP *Wgroup);
VOID FspWgroupSignalPermanently(FSP_WGROUP *Wgroup);
NTSTATUS FspWgroupWait(FSP_WGROUP *Wgroup,
KPROCESSOR_MODE WaitMode, BOOLEAN Alertable, PLARGE_INTEGER PTimeout);
/* silos */
typedef struct
{
@ -1125,6 +1147,7 @@ typedef struct
UINT64 InfoExpirationTime;
FSP_FSCTL_VOLUME_INFO VolumeInfo;
LONG VolumeNotifyLock;
FSP_WGROUP VolumeNotifyWgroup;
PNOTIFY_SYNC NotifySync;
LIST_ENTRY NotifyList;
FSP_STATISTICS *Statistics;