Answered step by step
Verified Expert Solution
Link Copied!

Question

1 Approved Answer

1. Typing ps alone lists the current running processes. lab3.c can be compiled as, gec -o lab3 lab3.c. The output of the program can be

image text in transcribed

image text in transcribedimage text in transcribed

image text in transcribed

1. Typing ps alone lists the current running processes. lab3.c can be compiled as, gec -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 13043 13133 TTY pts/0 pts/0 TIME 00:00:00 00:00:00 CMD bash 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: 13125 13126 PARENT CHILD 1 CHILD 2 13043 13124 BASH 13127 CHILD 3 Write the output of your program and draw a process three and label the processes with their process IDs. 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 Parent Process ID is CHILD 1 CHILD 2 Process ID is: Parent Process ID is CHILD 3 Process ID is: Parent Process ID is 1 2. 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 #include main () { int result ; printf("%d: printf ("%d: I am the parent. Remember my number! ", getpid(); 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 o result ); } else /* result == 0 */ { /* the child will execute this code */ printf("%d: Hi ! I am the child. ", getpid ()); exit (1) 5 } 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. Output I 2 S Process Tree

Step by Step Solution

There are 3 Steps involved in it

Step: 1

blur-text-image

Get Instant Access with AI-Powered 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

Students also viewed these Databases questions