Question: **The code after number 2 is the Lab03 file**Can I get some help with this lab and questions please? Part I: Process Management Practice 1.

**The code after number 2 is the Lab03 file**Can I get some help with this lab and questions please?

Part I: Process Management Practice 1. Download C code file lab03.c. Create a new empty file (# touch lab03.c). Type in the content of lab03.c to the lab03.c by using Vi/Vim (Vim is recommended due to its keyword highlighting feature). Save and exit the editor.

2). Install gcc (Linux C compiler) to your system (# yum install gcc) and compile the source code (# gcc lab03.c -o lab03), where -o indicate the output executable file. Thus, the executable file lab03 is created. If you see errors, double check if you typed anything wrong in the lab03.c file. Run lab03 (#./lab03) and answer questions below.

#include

#include

int main ()

{

pid_t fpid;

int count=0;

printf("the main process pid is %d ",getpid());

fpid=fork();

if (fpid < 0)

fprintf(stderr,"fork failed! ");

else if (fpid == 0) {

printf("i am the child process, my process id is %d ",getpid());

count++;

while(1){

//infinite loop

}

}

else {

printf("i am the parent process, my process id is %d ",getpid());

count++;

while(1){

//infinite loop

}

}

printf("count number is %d ",count);

return 0;

}

a. What pids are assigned to the parent process and the child process (to prove your

concept you should find some proof from the task/process manager).

b. Why the child process doesnt print main functions pid is xxxx?

c. Press Ctrl + z to switch both the child and parent process to the background and

monitor these processes with top. Explain what has been changed in the State

column of these processes.

d. Explain what happens if you kill the parent process but keep the child process alive

(Again, to prove your concept you should find some proof from the task/process

manager).

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!