Here code for $3$ processes are :
Process A {
while(1) { // see here infinite loop
P(S)
printf("*");
V(T)
}
}
Process B { // B executes only once
P(T)
V(Z)
}
Process C { // C executes exactly once
P(Z)
V(S)
}
Initially, $S =1 , T=0 , Z=0$, So, only Process $A$ can execute, and $*$ is printed once. After process $A$ completes $S =0 , T=1, Z=0$. $T = 1$ implies that only $B$ can execute now. After $B$ completes its execution $S =0, T=0 , Z=1$. Now $C$ executes and makes $S = 1$ ( both $B$ and $C$ are completed now). Again Process $A$ executes $1$ more time and prints $*$ once more.
So, Total number of times $*$ is printed $= 2$
The only thing to note here is that $A$ can execute infinitely(given $S= 1$), whereas $B$ and $C$ can execute only once. (no infinite loop)