Question: Linux Programming Assignment -3 Q1. Combine the two codes ([1] code with getppid(), getpid(), [2] code with system() call) given in theory-slides into one

Linux Programming Assignment -3 Q1. Combine the two codes ([1] code with getppid(), getpid(), [2] code withWhen referring to process IDs in a C or C++ program, always use the pid_t typedef, which is defined in . ACreating Processes Using system Listing 3.2 (system.c) Using the system Call #include int main() { int return

Linux Programming Assignment -3 Q1. Combine the two codes ([1] code with getppid(), getpid(), [2] code with system() call) given in theory-slides into one single code-block. Execute and measure total execution time of code-block. Plot a graph (X axis: execution instances four times (1, 2, 3, 4); Y axis: measured execution time). Hint: If execution time is too small to measure then insert a small delay-loop inside code to inflate execution time (do not insert large delay-loop). Submit your code, screen-shots and graph and your technical description (if any) as PDF. Students giving pseudo-code/flow-chart presentations will get additional advantages. When referring to process IDs in a C or C++ program, always use the pid_t typedef, which is defined in . A program can obtain the process ID of the process it's running in with the getpid() system call, and it can obtain the process ID of its parent process with the getppid() system call. For instance, the program in Listing 3.1 prints its process ID and its parent's process ID. Coding to get Process IDs Listing 3.1 (print-pid.c) Printing the Process ID #include #include int main () { } printf ("The process ID is %d ", (int) getpid ()); printf ("The parent process ID is %d ", (int) getppid ()); return 0; Creating Processes Using system Listing 3.2 (system.c) Using the system Call #include int main() { int return value; return value = system ("ls -1 /"); return return value; } The system function returns the exit status of the shell command. If the shell itself cannot be run, system returns 127; if another error occurs, system returns -1.

Step by Step Solution

There are 3 Steps involved in it

1 Expert Approved Answer
Step: 1 Unlock

As per your given assignment you need to combine the codes from Listing 31 related to getpid and get... View full answer

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 Programming Questions!