HP OpenVMS Systems

ask the wizard
Content starts here

Interlocks, Queues and Reentrancy?

» close window

The Question is:

I use the LIB$INS... and LIB$REM... queue
routines both for queues and stacks. Sometimes I
have a need to insert, remove or just examine an
entry at other locations than the head or tail.
Is there a recommended way to do that? This must
be an issue also with the OpenVMS timer and AST
queues assuming that these queues are
implemented using these routines (except for the
wrapper). One way I can think of to for exmaple
remove an entry in the middle is to remove head
and insert as tail to a temporary work queue
until the entry is encountered. And after
removing the entry then reattach the temporary
work queue using the tail of that queue and the
head of the remaining queue as routine
arguments. Another way is maybe to not use a
temporary work queue but instead insert a marker
entry as tail and then remove head and insert as
tail in the same queue until the entry is
encountered. And after removing the entry then
continue removing head and inserting as tail
until the marker is encountered and removed but
not inserted (obviously). This approach is
though more wasteful.
Thank you very much.

The Answer is :

  As you are undoubtedly aware, the interlocked queue operations
  use hardware- (VAX) or PALcode-assisted (Alpha) interlocks that
  are located in the queue header data structure.
  There are no general guidelines for using these interlocked
  queue operations away from the header, other than the obvious
  requirement that the access to the located entries within the
  queue -- entries that are not adjacent to the queue header --
  and any necessary queue entry traversals involved in this
  access be fully interlocked against any conflicting access.
  To ensure that the operations are reentrant for threading or
  for AST activites, in other words.
  The most appropriate solution depends on the application.
  Specific details of the implementation of the interlocked
  operations and of reentrancy are in the OpenVMS programming
  concepts and in the Alpha Architecture Reference Manual, and
  topics (2681) and (5199) may be of interest.  Some general
  programming tips for asynchronous programming are in topic
  (1661).  Details of achieving thread-reentrancy and the
  associated locking are in the DECthreads documentation.

answer written or last revised on ( 16-JUL-2001 )

» close window