Commit a7a722ddae4c ("SMPdesign: Work in the spacetime partitioning viewpoint") used raw line counts for referencing lines in Listing 6.5. Embedding line labels in the code snippet and using \clnref{} can reduce the risk of line-count mismatches in the future. Signed-off-by: Akira Yokosawa <akiyks@xxxxxxxxx> --- SMPdesign/SMPdesign.tex | 16 ++++++++++------ 1 file changed, 10 insertions(+), 6 deletions(-) diff --git a/SMPdesign/SMPdesign.tex b/SMPdesign/SMPdesign.tex index d0a9446b78a1..4d93c6e72f0b 100644 --- a/SMPdesign/SMPdesign.tex +++ b/SMPdesign/SMPdesign.tex @@ -208,6 +208,7 @@ has now become three statements due to the need to release the lock before returning. \begin{listing} +\begin{fcvlabel}[ln:SMPdesign:Code-Locking Hash Table Search] \begin{VerbatimL}[commandchars=\\\[\]] spinlock_t hash_lock; @@ -227,32 +228,35 @@ int hash_search(struct hash_table *h, long key) struct node *cur; int retval; - spin_lock(&hash_lock); + spin_lock(&hash_lock); \lnlbl[acq] cur = h->buckets[key % h->nbuckets]; while (cur != NULL) { if (cur->key >= key) { retval = (cur->key == key); - spin_unlock(&hash_lock); + spin_unlock(&hash_lock); \lnlbl[rel1] return retval; } cur = cur->next; } - spin_unlock(&hash_lock); + spin_unlock(&hash_lock); \lnlbl[rel2] return 0; } \end{VerbatimL} +\end{fcvlabel} \caption{Code-Locking Hash Table Search} \label{lst:SMPdesign:Code-Locking Hash Table Search} \end{listing} -Note that the \co{hash_lock} acquisition and release statements on lines~19, -24, and~29 are mediating ownership of the hash table among the CPUs -wishing to concurrently access that hash table. +\begin{fcvref}[ln:SMPdesign:Code-Locking Hash Table Search] +Note that the \co{hash_lock} acquisition and release statements on +\clnref{acq,rel1,rel2} are mediating ownership of the hash table among +the CPUs wishing to concurrently access that hash table. Another way of looking at this is that \co{hash_lock} is partitioning time, thus giving each requesting CPU its own partition of time during which it owns this hash table. In addition, in a well-designed algorithm, there should be ample partitions of time during which no CPU owns this hash table. +\end{fcvref} \QuickQuiz{ ``Partitioning time''? base-commit: bccd13b1e32770a985dfceb971ddf814785dcd41 -- 2.25.1