# Determining execution times of a concurrent system with exclusive resources

A certain system consists of 2 CPUs. The CPU that is not being used is assigned to a task whose execution is requested. On this system, two tasks, A and B, are executed.These tasks both use a common resource R exclusively.The CPU usage of the tasks A and B, the usage of resource R and the execution sequence are shown in the figure below.if both tasks are started at the same time, how long in ms will the completion of processing take for the two tasks?

a)120

b)140

c)150

d)200

According to this question, I understand the resource R is used exclusively by the CPUs, mean if one is using it, the other has to wait.

So my answer is d :

10 + 50 (first cpu) + 50(second cpu) + 60(first) + 30 (second) = 200


But the given answer is b, 140 :

10 + 50 + 60 + 20 = 140 ms


I don't get it, could someone explain to me?

Any help is greatly appreciated!

Task A will request R first and immediately get access to ist. So task A will take 10 + 50 + 60 = 120 ms. It will release R after 10 + 50 = 60 ms.

Task B will request R after 40 ms, but has to wait until 60 ms to get acess. Thus Task B will take 60 + 50 + 30 = 140 ms. (You can split the 60 into 40 (cpu) + 20 (waiting).)

The combined execution time is the maximum of the two, i.e. 140 ms.