5. T1 and T2 are two POSIX threads and s1 and s2 are two semaphores with initial values 1 and 0 consecutively in the
following C code segment. What are the contents of array b after execution of this code?
Int a[5] = {0,1,2,3,4};
Int b[5];
Int data;
T1() {
for(int i=0; i<5; i++)
{
sem_wait(&s1);
data = a[i]*a[i];
sem_post(&s2);
}
}
T2() {
for(int i=0; i<5; i++)
{
sem_wait(&s2);
b[i] = data;
sem_post(&s1);
}
}
a) {0,0,0,0,0}
b) {0,1,2,3,4}
c) {0,1,4,9,16}
d) Undetermined
Bo? b?rak