1
$\begingroup$

I am getting ready for my end of year exams and I got stuck on this question.

Consider the following 3-process concurrent program which uses semaphores S1,

Process 1
L1:
 P(S3);
 print("N");
 V(S2);
goto L1;

Process 2
L2:
 P(S1)
 printf("O");
 V(S3);
goto L2;

Process 3
L3:
 P(S2);
 print("C");
 V(S1);
gotoL3;

Are there initial values that can be given to the semaphores so that the processes cooperate to print the string CONCONCONCO? If so, give the initial values (identify which value is to be used for which semaphore) and explain how the string is printed.

I really don't understand the question, thank you for your help.

$\endgroup$
  • $\begingroup$ What part don't you understand? How semaphores work? How the three processes work? What the question is asking for? How to achieve it? Something else? $\endgroup$ – David Richerby May 9 '15 at 16:11
  • $\begingroup$ Do you mean they should print this finite string? It's hardly possible cause all the processes are endless, so if they start to print the repetitive CON, they will do that forever $\endgroup$ – HEKTO May 9 '15 at 19:13

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Browse other questions tagged or ask your own question.