Answered step by step
Verified Expert Solution
Link Copied!

Question

1 Approved Answer

Use pico to type and save the following program as labrep.c . Compile and run the program to observe that fork() returns the value of

Use pico to type and save the following program as labrep.c. Compile and run the program to observe that fork() returns the value of the childs PID to the parent process and zero to the child process. (You dont have to type the comments.)

#include 
#include 
main ( ) 
{
 int result ;
 
 printf("%d: I am the parent. Remember my number! ", getpid( ) ); 
 printf("%d: I am now going to fork ... ", getpid( ) ); 
 
 result = fork ( ) ; 
 
 if (result != 0) 
 { /* the parent will execute this code */ 
 printf("%d: My child's pid is %d ", getpid ( ), result ); 
 } 
 else /* result == 0 */
 { /* the child will execute this code */ 
 printf("%d: Hi ! I am the child. ", getpid ( ) ) ; 
 exit (1) ; 
 } 
 
 printf("%d: like father like son. ", getpid ( ) );
}

Write the output of the program. Draw a process three and label the processes with their process IDs.

Use this online terminal CoCalc to answer the question.

Solve this in 30 minutes and you will be granted an upvote. That's a promise.

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

JDBC Database Programming With J2ee

Authors: Art Taylor

1st Edition

0130453234, 978-0130453235

More Books

Students also viewed these Databases questions