#34 closed defect (fixed)
Added members to psDlist struct.
| Reported by: | Owned by: | eugene | |
|---|---|---|---|
| Priority: | high | Milestone: | |
| Component: | PSLib SDRS | Version: | unspecified |
| Severity: | minor | Keywords: | |
| Cc: |
Description
I added members to the psDlist struct ( PsLib SDRS section 3.4, 4/1/2004
version) to better support things like numbered indexing and thread safety. It
is defined in the implementation as:
/ Doubly-linked list */
typedef struct
{
unsigned int size; /< number of elements on list
psDlistElem* head; /< first element on list (may be NULL)
psDlistElem* tail; /< last element on list (may be NULL)
psDlistElem* iter; /< iteration cursor
unsigned int iterIndex; /< the numeric position of the
iteration cursor in the list
pthread_mutex_t lock; /< mutex to lock a node during changes
}
psDlist;
The 'size' member caches the number of elements in the list (to simplify range
checking of numbered indexes into the list).
The 'iterIndex' member caches the current numbered location of the iter pointer
to allow efficient indexing via numbers (can calculate relative position from
last index instead of always starting from the beginning of list).
The 'lock' member allows exclusive access to the list so that actions that
add/remove elements, change the iterator position, or depend on the list's size
are done in a thread-safe method.
Change History (2)
comment:1 by , 22 years ago
| Resolution: | → fixed |
|---|---|
| Status: | new → closed |
comment:2 by , 22 years ago
Just to answer your question: I designed it so that the whole list is locked
during an access operation, not individual nodes. I didn't think we needed to
go down to the individual nodes; that just adds complexity and possible
increased risk of deadlock. I just added basic thread safety to protect a
function that is transversing the list from a function that is changing the list
(add/remove/etc.).
-rdd

these look fine. does mutex lock only a node (how does the other thread know
which node is locked?) or the whole list?