Answered step by step
Verified Expert Solution
Link Copied!

Question

1 Approved Answer

Proper includes and declarations have been made but not shown below ( pseudo - code ) . The size of an integer is 4 bytes

Proper includes and declarations have been made but not shown below (pseudo-code). The size of an
integer is 4 bytes and this of a character is 1 byte. Based on the snippet below, investigate the following:
Q1: Remove lines A and C altogether but keep B and D.
Q2: Remove lines B and D altogether but keep A and C.
In Q1 and Q2 what are the final values of r1, r2, r3, r5, r6, r7? Are there orphans or zombies at the end?
int pipefd[2];
pid_t res; //size of res is 8 bytes
char ch[50];
int r1, r2, r3, r4, r5, r6, r7;
pipe(pipefd);
res = fork();
if (res >0){
sleep(5); // line A
r1= write(pipefd[1],&res,2*sizeof(r4));
sleep(5); // line B
r2= write(pipefd[1],&r1,2*sizeof(char));
printf(Finished!);
r7= waitpid(-1,&status,WUNTRACED|WNOHANG);
sleep(20);
close(pipefd[

Step by Step Solution

There are 3 Steps involved in it

Step: 1

blur-text-image

Get Instant Access to Expert-Tailored Solutions

See step-by-step solutions with expert insights and AI powered tools for academic success

Step: 2

blur-text-image

Step: 3

blur-text-image

Ace Your Homework with AI

Get the answers you need in no time with our AI-driven, step-by-step assistance

Get Started

Recommended Textbook for

Oracle Databases On The Web Learn To Create Web Pages That Interface With Database Engines

Authors: Robert Papaj, Donald Burleson

11th Edition

1576100995, 978-1576100998

More Books

Students also viewed these Databases questions