RTL_RCU_STATE - NtDoc

Native API online documentation, based on the System Informer (formerly Process Hacker) phnt headers
#ifndef _NTRTL_H
#if (PHNT_VERSION >= PHNT_WINDOWS_11)
//
// Read-Copy-Update (RCU).
//
// RCU synchronization allows concurrent access to shared data structures,
// such as linked lists, trees, or hash tables, without using traditional locking methods
// in scenarios where read operations are frequent and need to be fast.
// It is particularly useful in multi-threaded environments where multiple threads
// may read from the same data structure while one or more threads may modify it.
// @remarks RCU synchronization is not for general-purpose synchronization.
// Teb->Rcu is used to store the RCU state.
#if defined(PHNT_NATIVE_RCU)

//typedef struct _RTL_RCU_THREAD_ENTRY RTL_RCU_THREAD_ENTRY, *PRTL_RCU_THREAD_ENTRY;
//typedef struct _RTL_RCU_SEGMENT      RTL_RCU_SEGMENT,      *PRTL_RCU_SEGMENT;

// rev
typedef struct _RTL_RCU_STATE
{
    //
    // Global list links (inserted by RtlRcuAllocate under a global SRW lock).
    //
    struct _RTL_RCU_STATE *GlobalNext;
    struct _RTL_RCU_STATE *GlobalPrev;

    //
    // Global epoch/state.
    //
    volatile ULONGLONG Epoch;

    //
    // Segmented array root used by RtlpRcuCurrentThreadData()
    // to map "thread-id-like" (ebx) -> RTL_RCU_THREAD_ENTRY*.
    //
    PRTL_RCU_SEGMENT SegmentRoot;

    //
    // Singly-linked list of all per-thread entries for this state.
    // synchronize walks this list and waits on each entry->SeenEpoch.
    //
    PRTL_RCU_THREAD_ENTRY ThreadList;

    //
    // Small cache indexed by (ebx % 10) (the 0xCCCCCCCD multiply trick).
    //
    PRTL_RCU_THREAD_ENTRY Cache[10];

    //
    // Slow-path SRW lock used when RtlpRcuCurrentThreadData() returns NULL.
    //  - ReadLock uses AcquireSRWLockShared(&state+0x78)
    //  - Synchronize uses Acquire/Release Exclusive on &state+0x78 (via helper)
    //
    RTL_SRWLOCK SlowPathLock;

    //
    // Stored from RtlRcuAllocate(ecx)
    //
    ULONG TagOrFlags;

    ULONG Padding; // (to make sizeof == 0x88 on x64)
} RTL_RCU_STATE, *PRTL_RCU_STATE;

#endif
#endif
#endif

View code on GitHub

NtDoc

No description available.