Typing ps alone lists the current running processes. lab3.c can be compiled as, gcc –o lab3 lab3.c. The output of the program can be obtained by typing: ./lab3. Below are the examples of the possible outputs that would be generated by the ps and ./lab3 commands:  ps  ./lab3  PID     TTY     TIME       CMD  13043   pts/0   00:00:00   bash  13133   pts/0   00:00:00   ps    Process ID is: 13126  Parent Process ID is 13125  Process ID is: 13125  Parent Process ID is 13124  Process ID is: 13127  Parent Process ID is 13124  Process ID is: 13124  Parent Process ID is 13043    Please remember that PID value of bash (Unix command shell) is 13043 for this example. So the process tree can be drown by using the above information as:    Write the output of your program and draw a process three and label the processes with their process IDs.  Output  Process Tree  Process ID is: _________  Parent Process ID is _________  Process ID is: _________  Parent Process ID is _________  Process ID is: _________  Parent Process ID is _________  Process ID is: _________  Parent Process ID is _________

Computer Networking: A Top-Down Approach (7th Edition)
7th Edition
ISBN:9780133594140
Author:James Kurose, Keith Ross
Publisher:James Kurose, Keith Ross
Chapter1: Computer Networks And The Internet
Section: Chapter Questions
Problem R1RQ: What is the difference between a host and an end system? List several different types of end...
icon
Related questions
Question
  1. Typing ps alone lists the current running processes. lab3.c can be compiled as, gcc –o lab3 lab3.c. The output of the program can be obtained by typing: ./lab3. Below are the examples of the possible outputs that would be generated by the ps and ./lab3 commands: 

ps 

./lab3 

PID     TTY     TIME       CMD 

13043   pts/0   00:00:00   bash 

13133   pts/0   00:00:00   ps 

 

Process ID is: 13126 

Parent Process ID is 13125 

Process ID is: 13125 

Parent Process ID is 13124 

Process ID is: 13127 

Parent Process ID is 13124 

Process ID is: 13124 

Parent Process ID is 13043 

 

Please remember that PID value of bash (Unix command shell) is 13043 for this example. So the process tree can be drown by using the above information as: 

 

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

Output 

Process Tree 

Process ID is: _________ 

Parent Process ID is _________ 

Process ID is: _________ 

Parent Process ID is _________ 

Process ID is: _________ 

Parent Process ID is _________ 

Process ID is: _________ 

Parent Process ID is _________ 

 

 

  1. 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 child’s PID to the parent process and zero to the child process. (You don’t have to type the comments.) 

#include <stdio.h> 

#include <stdlib.h> 

main ( )  

{ 

 int  result ; 

  

 printf("%d:  I am the parent. Remember my number!\n", getpid( ) );   

 printf("%d:  I am now going to fork ... \n", getpid( ) );  

 

   result = fork ( ) ;  

   

   if (result != 0)  

   {    /* the parent will execute this code */  

     printf("%d:  My child's pid is %d\n", getpid ( ), result );  

   }  

   else     /* result == 0 */ 

   {        /* the child will execute this code */  

      printf("%d:  Hi !  I am the child.\n", getpid ( ) ) ;         

      exit (1) ;  

   }  

      

      printf("%d:  like father like son. \n", getpid ( ) ); 

} 

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

Output 

 

 

 

 

 

 

 

 

 

 

Process Tree 

 

 

 

 

 

 

 

Expert Solution
steps

Step by step

Solved in 2 steps with 1 images

Blurred answer
Recommended textbooks for you
Computer Networking: A Top-Down Approach (7th Edi…
Computer Networking: A Top-Down Approach (7th Edi…
Computer Engineering
ISBN:
9780133594140
Author:
James Kurose, Keith Ross
Publisher:
PEARSON
Computer Organization and Design MIPS Edition, Fi…
Computer Organization and Design MIPS Edition, Fi…
Computer Engineering
ISBN:
9780124077263
Author:
David A. Patterson, John L. Hennessy
Publisher:
Elsevier Science
Network+ Guide to Networks (MindTap Course List)
Network+ Guide to Networks (MindTap Course List)
Computer Engineering
ISBN:
9781337569330
Author:
Jill West, Tamara Dean, Jean Andrews
Publisher:
Cengage Learning
Concepts of Database Management
Concepts of Database Management
Computer Engineering
ISBN:
9781337093422
Author:
Joy L. Starks, Philip J. Pratt, Mary Z. Last
Publisher:
Cengage Learning
Prelude to Programming
Prelude to Programming
Computer Engineering
ISBN:
9780133750423
Author:
VENIT, Stewart
Publisher:
Pearson Education
Sc Business Data Communications and Networking, T…
Sc Business Data Communications and Networking, T…
Computer Engineering
ISBN:
9781119368830
Author:
FITZGERALD
Publisher:
WILEY