How to you solve the problem of implicit locking and parallel execution?
- by Eonil
Where the code is:
function A()
{
lock()
doSomething()
unlock()
}
We can call A safely from multiple threads, but it never be executed in parallel . For parallel execution, we have to evade all of this code.
But the problem is we never know the A is getting lock or not. If we have source code (maybe lucky case), we have to decode all code to know locking is happening or not. This sucks. But even worse is we normally have no source code.
It's obvious this kind of hidden locks will become bottleneck of parallel execution even all the other parts are designed for parallel.
And also, (1) With locks, execution cannot be parallel. (2) And I can't know whether the locks are used or not in any code. (3) Defensively, I can't make parallel anything!
This facts drives me crazy. How do you solve this problem?