Question: Process P1 init(mutEx); num = 0; loop1 = 0; while (loop1 < 3) wait(mutEx); num = num + 1; signal(mutEX); loop1 = loop1 + 1;
Process P1
init(mutEx); num = 0; loop1 = 0; while (loop1 < 3) wait(mutEx); num = num + 1; signal(mutEX); loop1 = loop1 + 1;
Process P2
loop2 = 0; while (loop2 < 2) wait(mutEx); num = num + 10; signal(mutEX); loop2 = loop2 + 1;
Assume all variables are shared for P1 and P2. This is a single core system. We will start with P1. The CPU will execute 5 lines of code before switching processes. What is the value of num after both processes finish executing?
Step by Step Solution
There are 3 Steps involved in it
Get step-by-step solutions from verified subject matter experts
