This corresponds to the NT syscall NtCreateMutant(). An NT mutex is recursive, with a 32-bit recursion counter. When acquired via NtWaitForMultipleObjects(), the recursion counter is incremented by one. The OS records the thread which acquired it. The OS records the thread which acquired it. However, in order to keep this driver self-contained, the owning thread ID is managed by user-space, and passed as a parameter to all relevant ioctls. The initial owner and recursion count, if any, are specified when the mutex is created.
Showing the changes to include/uapi (1 of 2 files). Show all
Unified · Split
| @@ -15,6 +15,11 @@ struct ntsync_sem_args { · 14 unmodified lines | |||
| 15 | __u32 max; | 15 | __u32 max; |
| 16 | }; | 16 | }; |
| 17 | 17 | ||
| 18 | struct ntsync_mutex_args { | ||
| 19 | __u32 owner; | ||
| 20 | __u32 count; | ||
| 21 | }; | ||
| 22 | |||
| 18 | #define NTSYNC_WAIT_REALTIME 0x1 | 23 | #define NTSYNC_WAIT_REALTIME 0x1 |
| 19 | 24 | ||
| 20 | struct ntsync_wait_args { | 25 | struct ntsync_wait_args { |
| @@ -23,7 +28,8 @@ struct ntsync_wait_args { · 2 unmodified lines | |||
| 23 | __u32 count; | 28 | __u32 count; |
| 24 | __u32 index; | 29 | __u32 index; |
| 25 | __u32 flags; | 30 | __u32 flags; |
| 26 | __u32 pad[3]; | 31 | __u32 owner; |
| 32 | __u32 pad[2]; | ||
| 27 | }; | 33 | }; |
| 28 | 34 | ||
| 29 | #define NTSYNC_MAX_WAIT_COUNT 64 | 35 | #define NTSYNC_MAX_WAIT_COUNT 64 |
| @@ -31,6 +37,7 @@ struct ntsync_wait_args { · 1 unmodified line | |||
| 31 | #define NTSYNC_IOC_CREATE_SEM _IOW ('N', 0x80, struct ntsync_sem_args) | 37 | #define NTSYNC_IOC_CREATE_SEM _IOW ('N', 0x80, struct ntsync_sem_args) |
| 32 | #define NTSYNC_IOC_WAIT_ANY _IOWR('N', 0x82, struct ntsync_wait_args) | 38 | #define NTSYNC_IOC_WAIT_ANY _IOWR('N', 0x82, struct ntsync_wait_args) |
| 33 | #define NTSYNC_IOC_WAIT_ALL _IOWR('N', 0x83, struct ntsync_wait_args) | 39 | #define NTSYNC_IOC_WAIT_ALL _IOWR('N', 0x83, struct ntsync_wait_args) |
| 40 | #define NTSYNC_IOC_CREATE_MUTEX _IOW ('N', 0x84, struct ntsync_mutex_args) | ||
| 34 | 41 | ||
| 35 | #define NTSYNC_IOC_SEM_RELEASE _IOWR('N', 0x81, __u32) | 42 | #define NTSYNC_IOC_SEM_RELEASE _IOWR('N', 0x81, __u32) |
| 36 | 43 | ||