Home Upgrade Search Memberlist Extras Hacker Tools Award Goals Help Wiki Contact

C 

precedence graph with semaphores

🙃Hey there, I am working on system programming for the last weeks, and I'm trying to grasp some major concepts.
I am writing C in Linux OS.

P1 process code:
Code
while(true){
print(P)
print(I)
}

P2 process code:
Code
while(true){
print(Z)
}

P3 process code:
Code
while(true){
print(A)
}

I have achieved to use P and V semaphores to print PIZZA once with the code below:

Code
var Σ12, Σ13, Σ23: semaphores;
Σ12:= Σ13:= Σ23:= 0;
cobegin
begin Δ1; V(Σ12); V(Σ13); end;
begin P(Σ12); Δ2; V(Σ23);end;
begin P(Σ13);P(Σ23); Δ3;end;
coend

What if I want to use the same 3 semaphores to print :

Code
PIZZAPIZZAPIZZAPIZZA.......
(forever).

Thanks in advance. ✌


Possibly Related Threads...
Thread / Author Replies Views Last Post
[Legends] by DystortionFeb 11, 2026 04:09 PM 4 155 Feb 11, 2026 04:09 PM
Last Post: Dystortion
[Python] by MiguelSanchezJan 30, 2022 01:36 AM 2 128 Jan 30, 2022 01:36 AM
Last Post: MiguelSanchez
[C] by georgeziozasJan 19, 2021 12:14 AM 2 181 Jan 19, 2021 12:14 AM
Last Post: Juice