How to answer this? please help.
Consider the following program with 3 threads.
locks l1, l2, l3;
*Thread 1
while(1){
l1.lock();
l2.lock();
printf(“Red”);
l3.unlock();
l1.unlock();}
*Thread 2
while(1){
l2.lock();
l3.lock();
printf(“Green”);
l1.unlock();
l2.unlock();}
*Thread 3
while(1){
l3.lock();
l1.lock();
printf(“Blue”);
l2.unlock();
l3.unlock();}
a) What are the possible outcomes of the above program. Can you explain how this'll happen? b) Will this code lead to a deadlock?