language-iconOld Web
English
Sign In

Sentinel node

In computer programming, a sentinel node is a specifically designated node used with linked lists and trees as a traversal path terminator. This type of node does not hold or reference any data managed by the data structure. In computer programming, a sentinel node is a specifically designated node used with linked lists and trees as a traversal path terminator. This type of node does not hold or reference any data managed by the data structure. Sentinels are used as an alternative over using null as the path terminator in order to get one or more of the following benefits: However, sentinel nodes rely on shared memory, which requires extra code to avoid data races. This causes sentinel nodes to have poor performance on concurrent systems. Below are two versions of a subroutine (implemented in the C programming language) for looking up a given search key in a singly linked list. The first one uses the sentinel value NULL, and the second one a (pointer to the) sentinel node Sentinel, as the end-of-list indicator. The declarations of the singly linked list data structure and the outcomes of both subroutines are the same. The for-loop contains two tests (yellow lines) per iteration: The globally available pointer sentinel to the deliberately prepared data structure Sentinel is used as end-of-list indicator. The for-loop contains only one test (yellow line) per iteration: If the data structure is accessed concurrently then for a sentinel-based implementation, not only the node pointed to by first has to be protected for “read-only” by a mutex, but also the node Sentinel has to be protected for “read-write”; this extra mutex in quite a few use scenarios can cause severe performance degradation . One way to avoid it is to protect the list structure as a whole for “read-write”, whereas in the first version (with end-of-list indicator NULL) it suffices to protect the list structure as a whole for “read-only” (if an update operation will not follow).

[ "Breast cancer", "Lymph node", "Macrometastasis", "Isosulfan Blue", "Inguinofemoral Lymphadenectomy", "Lymphatic mapping", "Axillary Node Dissection" ]
Parent Topic
Child Topic
    No Parent Topic
Baidu
map