Information Technology Reference
In-Depth Information
On the other hand, the approach is not wait-free since it cannot bound the
number of retries needed for a transaction to successfully commit|in the worst
case, it is possible for a given transaction to starve forever if it encounters a
stream of conflicing transactions that always manage to beat it in the race to
commit.
Although much work on transactions has been done in the context of databases
that store data on disk, software transactional memory (STM) is a promising
Definition: software
transactional memory
(STM)
approach to allow transactions on in-memory data structures. Unfortunately,
the cost of an STM transaction is often significantly higher than that of a tradi-
tional critical section because of the need to maintain the state needed to check
dependencies and the state needed either to update the object if there is no
conflict or to roll back its state if a conflict is detected. On the other hand,
in situations where STM can be used, it provides a way to compose different
modules without having to worry about deadlock.
Exercises
6. In RCUlist::remove() , suppose we attempt to maximize concurrency
by replacing the WriteLock() and WriteUnlock() calls with ReadLock()
and ReadUnlock() calls and insert new WriteLock() and writeUnlock()
calls at beginning and end of the code that is executed only if the if
conditional test succeeds. The basic idea is to hold a read lock while
searching for the target item an to grab the write lock once it is found.
Will this work?
6.4
Conclusion
The quotes introducing this chapter are intended to emphasize that advanced
synchronization techniques should be approached with caution. Your first goal
should be to construct a program that works, even it doing so means putting
\one big lock" around everything in a data structure or even in an entire pro-
gram.
Resist the temptation to do complicated fine grained locking (let alone RCU)
unless you know that doing so is necessary. How do you know? Don't guess.
Measure your system's performance. (Measuring the \before" and \after" per-
formance of a program and its subsytems not only helps you make good decisions
about the program on which you are working, but it also will help you develop
good intuition for the programs you face in the future.)
Spend a lot of time early in the design process developing a clean structure
for your program.
Given that multi-object synchronization and deadlock are
Search WWH ::




Custom Search