Question: Select ALL that apply. Assume all the proper #includes and declarations have been made, and that all system calls execute without error. The size of

Select ALL that apply. Assume all the proper #includes and declarations have been made, and that all system calls execute without error. The size of an pid_t variable is 8 bytes and the size of an integer is 4 bytes for this system. Based on the snippet below (THIS IS PSEUDO-CODE) answer the following questions (MULTIPLE ANSWERS):
int pipefd[2];
pid_t res;
int r1, r2, r3, r4, r5;
pipe(pipefd);
res = fork();
if (res >0){
r1= write(pipefd[1],&res,2*sizeof(r4));
sleep(10);
r3= write(pipefd[1],&res,2*sizeof(char));
printf(Finished!);
close(pipefd[1]);
}
else if (res ==0){
close(pipefd[1]);
r2= read(pipefd[0],&r3, sizeof(r4));
r5= read(pipefd[0],&r3,3*sizeof(r4));
r3= read(pipefd[0],&r3,2*sizeof(char));
sleep(30);
r1= read(pipefd[0],&r4,sizeof(r4));
}
exit(0);
Group of answer choices
Possible case for values r2, r1, r3 are: positive, 4,2
Possible case for values r2, r5, r1 are: 4, positive, 0
If somehow we manage to go past the second sys call in the child, then the third sys call is blocking;
If we delete the first sys call read in the child, then the third sys call read blocks and r3<0;
The second sys call read for the child is blocking because the child waits to read more bytes than what was written in the pipe.
The second sys call read for the child is unsuccessful because the argument size is not correct.
If somehow we manage to go past the third sys call in the child, then the fourth sys call is blocking
If we delete the second sys call in the child, then the fourth syscall read returns with r1=4

Step by Step Solution

There are 3 Steps involved in it

1 Expert Approved Answer
Step: 1 Unlock blur-text-image
Question Has Been Solved by an Expert!

Get step-by-step solutions from verified subject matter experts

Step: 2 Unlock
Step: 3 Unlock

Students Have Also Explored These Related Databases Questions!