Is there a cross-platform version of Windows Vista for thin readers?

I was completely blown away by the quality implementation of Windows SRW. Its faster than critical sections, and with a few extra bytes of memory.

Unfortunately, this is only Windows Vista / Windows 7.

How is this a pure user implementation of the land, does anyone know if there is a cross-platform implementation for it? Has anyone drew their decision?

And please, I do not want to add things like boost to pull out less than 100 LOC solutions.

+3
source share
2 answers

- "" ... POSIX, pthread_rwlock_init() . , Windows, Unix.

"" " Windows..." ntdll, RW. RtlAcquireResourceShared() RtlAcquireResourceExclusive().

WINE:

void WINAPI RtlInitializeResource(LPRTL_RWLOCK rwl);
void WINAPI RtlDeleteResource(LPRTL_RWLOCK rwl);
BYTE WINAPI RtlAcquireResourceExclusive(LPRTL_RWLOCK rwl, BYTE fWait);
BYTE WINAPI RtlAcquireResourceShared(LPRTL_RWLOCK rwl, BYTE fWait);
void WINAPI RtlReleaseResource(LPRTL_RWLOCK rwl);

, GetProcAddress() ntdll.dll .

, ... WINE:

typedef struct _RTL_RWLOCK {
   RTL_CRITICAL_SECTION rtlCS;

   HANDLE hSharedReleaseSemaphore;
   UINT   uSharedWaiters;

   HANDLE hExclusiveReleaseSemaphore;
   UINT   uExclusiveWaiters;

   INT    iNumberActive;
   HANDLE hOwningThreadId;
   DWORD  dwTimeoutBoost;
   PVOID  pDebugInfo;
} RTL_RWLOCK, *LPRTL_RWLOCK;

pthreads ... rwlock ... InterlockedCompareExchange(), , , , .

+3

, , , rwlock ( , , , ). .

"" , . , , , (.. (2) (3) ).

- Windows, pthread condvars, . , , - ( pause, CPU), , .

, , LOC. ( , ), (, slim lock, ).

0

Source: https://habr.com/ru/post/1725024/


All Articles