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.
- "" ... POSIX, pthread_rwlock_init() . , Windows, Unix.
pthread_rwlock_init()
"" " Windows..." ntdll, RW. RtlAcquireResourceShared() RtlAcquireResourceExclusive().
ntdll
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 .
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(), , , , .
InterlockedCompareExchange()
, , , rwlock ( , , , ). .
"" , . , , , (.. (2) (3) ).
- Windows, pthread condvars, . , , - ( pause, CPU), , .
pause
, , LOC. ( , ), (, slim lock, ).
Source: https://habr.com/ru/post/1725024/More articles:Duplicating triple in RDF, authoritative look? - rdfUsing the built-in DLL? - c #Which languages โโother than Python have an explicit self? - pythonhttps://translate.googleusercontent.com/translate_c?depth=1&pto=aue&rurl=translate.google.com&sl=ru&sp=nmt4&tl=en&u=https://fooobar.com/questions/1725022/should-actionresult-perform-other-tasks-too&usg=ALkJrhioS66YQawFXRfuj_ML5QMjQBIEjgCan someone explain to me what the value of the logical parameter of the System.Xml.XmlDictionaryWriter.WriteNode (XmlReader, bool) method means? - xmlะะฐะบ ัะดะตะปะฐัั Windows slim read writer lock fair? - c++Is there any free / open source engine for the iPhone? - iphonePreventing color bleeding with StateImageList on TreeView - c #Using (void *) as an identifier type - c ++Scrolling up / down when choosing a multi-page block of text in Vim through putty - vimAll Articles