Question: Instructions: 1. Solve problem 5.1, 5.2, 5.3 and problem 5.4 given in Lab Manual No. 3. 2. Write the solution of problem 5.1, 5.2, 5.3

 Instructions: 1. Solve problem 5.1, 5.2, 5.3 and problem 5.4 given
in Lab Manual No. 3. 2. Write the solution of problem 5.1,
5.2, 5.3 and problem 5.4 in "vi editor. Take the screenshot and
put the picture in solution section of each question. 3. Run the
code and take the screenshot of output and put the picture in

Instructions: 1. Solve problem 5.1, 5.2, 5.3 and problem 5.4 given in Lab Manual No. 3. 2. Write the solution of problem 5.1, 5.2, 5.3 and problem 5.4 in "vi editor. Take the screenshot and put the picture in solution section of each question. 3. Run the code and take the screenshot of output and put the picture in output section of each question. Problem 5.1: Following program demonstrates the use of fork ( ). Write this program in Oracle VM VirtualBox, compile it and run it according to lab instructor instructions and study the output. Put the screenshot of code after writing in "vi editor" in solution section and screenshot of output in output section. #include #include /* contains fork prototype */ int main(void) { printf("Hello World! "); fork(); printf("I am after forking "); printf("\tI am process %d. ", getpid()); } Solution Section: Write above code in "vi editor" and put "screenshot" here...... Output Section: Put "screenshot" of output here...... Problem 5.2: Following program demonstrates the use of fork ( and getpid. Write this program in Oracle VM VirtualBox, compile it and run it according to lab instructor instructions and study the output. Put the screenshot of code after writing in "vi editor" in solution section and screenshot of output in output section. #include #include /* contains fork prototype */ int main(void) int pid; printf("Hello World! "); printf("I am the parent process and pid is : %d. ",getpid()); printf("Here i am before use of forking "); pid - forko; printf("Here I am just after forking "); if (pid=0) printf("I am the child process and pid is :%d. ",getpid()); else printf("I am the parent process and pid is: %d. ",getpido); } Solution Section: Write the code of above question in "vi editor" and put "screenshor" here........ Output Section: Put "screenshot" of output here............................ Problem 5.3: Following program demonstrates the use of fork ( ) more than one time. Write this program in Oracle VM VirtualBox, compile it and run it according to lab instructor instructions and study the output. Put the screenshot of code after writing in "vi editor" in solution section and screenshot of output in output section. #include #include * contains fork prototype */ main(void) { printf("Here I am just before first forking statement "); fork(); printf("Here I am just after first forking statement "); fork(); printf("Here I am just after second forking statement "); printf("\t\tHello World from process %d! ", getpid()); } Solution Section: Write above code in "vi editor" and put "screenshot" here........ Output Section: Put "screenshot" of output here...... Problem 5.4: Following program demonstrates the use of perfor function. Write this program in Oracle VM VirtualBox, compile it and run it according to lab instructor instructions and study the output Put the screenshot of code after writing in "Vi editor" in solution section and screenshot of output in output section. #include #include /* contains prototype for wait * int main(void) { int pid; int status: printf("Hello World!n"); pid=fork(); if (pid --1)/ check for error in fork/ perror("bad fork"); exit(); } if (pid=0) printf("I am the child process. In"); else printf("I am the parent process. In"); } Solution Section: Write the code of above question in "vi editor" and pur screenshor" here.......... Output Section: Put "screenshot of output here

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!