Академический Документы
Профессиональный Документы
Культура Документы
NET, this is simply a matter of not recycling nodes. That is, once a node has been popped, never push it again. Instead allocate a fresh node. The garbage collector will do the hard wor of chec ing that the memory for node A is not recycled until all e!tant references to it are gone. In languages with garbage collection, the problem is harder. An old techni"ue dating bac to the IB# $%& changes ABA to ABA. In other words, ma e A slightly different each time. Another solution is to build a miniature garbage collector that handles pointers involved in compare' e!change operations. These pointers are called ha (a rd pointers, because they present a ha(ard to loc less algorithms.
RECOMMENDATIONS:
Non'bloc ing algorithms big advantage is avoiding loc pathologies. Their primary disadvantage is that they are much more complicated than their loc ed counterparts. Non'bloc ing algorithms are difficult to verify. None!perts should consider the following advice) Atomic increment, decrement, and fetch'and'add are generally safe to use in an intuitive fashion. The fetch'and'op idiom is generally safe to use with operations that are commutative and associative. The creation of non'bloc ing algorithms for lin ed data structures should be left to e!perts. 0se algorithms from the peer'reviewed literature. Be sure to understand any memory reclamation issues. Avoid having more runnable software threads than hardware threads, and design programs to avoid loc contention.
+i, BAND-IDTH:
To conserve bandwidth, pac data more tightly, or move it lessfre"uently between cores. 2ac ing the data tighter is usuallystraightforward, and benefits se"uential e!ecution as well. ,or e!ample, 1hen declaring structures in -.-//, declare fields in order ofdescending si(e. This strategy tends to minimi(e the e!tra padding that the compiler must insert to maintain alignment re"uirements, as e!emplified.
3ome compilers also support 4pragma pac directives that pac structures even more tightly, possibly by removing all padding.
3uch verytight pac ing may be counterproductive, however, because it causes misaligned loads