Question
Can I get some help with this lab and questions please?**THE CODE UNDER NUMBER 2 IS THE LAB03 FILE** Part I: Process Management Practice 1.
Can I get some help with this lab and questions please?**THE CODE UNDER NUMBER 2 IS THE LAB03 FILE**
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/pr
Step by Step Solution
There are 3 Steps involved in it
Step: 1
Get Instant Access to Expert-Tailored Solutions
See step-by-step solutions with expert insights and AI powered tools for academic success
Step: 2
Step: 3
Ace Your Homework with AI
Get the answers you need in no time with our AI-driven, step-by-step assistance
Get Started