Product Documentation

c-treeACE V11.0 Update Guide

Previous Topic

Next Topic

ctThrdSharedCritical API for Scalable Read Locks

This release extends the threading API for reader/writer lock support that allow uncontended read locks for excellent speed and scalability. Shared lock performance should scale linearly. Exclusive lock performance is expected to be slower than alternatives.

NINT ctThrdSharedCriticalInit(ctSCRIT * scrit)

Initializes the shared critical pointed to by scrit.

Returns 0 on success.

NINT ctThrdSharedCriticalEnter(ctSCRIT * scrit, volatile RESERVATION * ticket)

A shared lock of scrit. Each calling thread must have a unique RESERVATION they provide to each scrit. There are multiple restrictions on ticket:

  1. The RESERVATION must initialize as shown prior to first calling this function:
    *ticket = CRIT_UNRESERVED
  2. Behavior is undefined if the RESERVATION is modified at any time after first use and prior to calling ctThrdSharedCriticalCancelReservation
  3. Behavior is undefined if ticket becomes invalid memory prior to calling ctThrdSharedCriticalCancelReservation for this scrit and ticket.
  4. Behavior is undefined if ticket is used by a different thread.
  5. Behavior is undefined if the thread exits without calling ctThrdSharedCriticalCancelReservation for this scrit and ticket.

Behavior is undefined if called recursively.

Waits indefinitely if an Exclusive lock is in effect.

Note: False sharing of RESERVATION memory could impact scalability.

Returns 0 on success.

NINT ctThrdSharedCriticalExit(ctSCRIT * scrit, volatile RESERVATION * ticket)

Releases the shared lock of scrit. The same ticket passed by this thread to ctThrdSharedCriticalEnter must be used.

Returns 0 on success.

NINT ctThrdSharedCriticalCancelReservation(ctSCRIT * scrit, volatile RESERVATION * ticket)

Releases resources in scrit associated with ticket. This must be called prior to thread exit once a particular ticket has been passed to ctThrdSharedCriticalEnter.

Returns 0 on success.

NINT ctThrdSharedCriticalEnterExcl(ctSCRIT * scrit)

An exclusive lock of scrit. Behavior is undefined if called recursively.

Returns 0 on success.

NINT ctThrdSharedCriticalExitExcl(ctSCRIT * scrit)

Releases an exclusive lock of scrit.

Returns 0 on success.

NINT ctThrdSharedCriticalTerm(ctSCRIT * scrit)

Releases resources used by shared critical. Behavior is undefined if scrit is still in use by other threads.

TOCIndex