starposの日記

思ったこと感じたこと考えたことを書く

Almost the same interface of both optimistic and pessimistic transaction processing.

I feel the interface of the STM is very attractive, but we need a pessimistic implementation sometimes, for example, when many threads concentrate into one resource at the same time, the overhead of first try of all threads is not ignorable. Even in such situations, we want to avoid dead locks.

The goal should be both optimistic and pessimistic implementations are available with almost the same interface, and programmers can choose any of them to suit the nature of their writing transactional program.

Some wrapper may be required to construct a pessimistic implementation with the same interface as STM. If all resources managed in a transaction system have a total order, and programs do not lock resources by themselves and delegate lock operations to the underlying system, then the system can decide the order of resources to be locked for each transaction, then it must realize dead-lock-free pessimistic transaction processing...

Is this thought reasonable? Or has someone already made some papers or implementations like this?