How to you solve the problem of implicit locking and parallel execution?

Posted by Eonil on Programmers See other posts from Programmers or by Eonil
Published on 2011-06-29T08:00:38Z Indexed on 2011/06/29 8:30 UTC
Read the original article Hit count: 207

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?

© Programmers or respective owner

Related posts about multi-threading

Related posts about Parallelism