multithreadingconcurrencyprocessorconcurrent-processing

In concurrent programming is it possible that, by using locks, a program might sometimes use more processors than are necessary?


This is an exam question (practice exam, not the real one). It's about concurrent programming using a multi-core processor and the problems with using locks.

In concurrent programming is it possible that, by using locks, a program might sometimes use more processors than are necessary

In other words, is this ever possible? It's a true/false question. I can't find an answer anywhere and I'm revising for my exams.


Solution

  • The concurrent program with N threads of execution using locks at any point in time can have M=0 .. N-1 threads waiting for locks; thus this program can only be utilizing N-M processors since waiting for a lock does not require a processor. Thus, no, using locks does not increase the number of processors required by a concurrent program.