Linux Programming Assignment -3 Q1. Combine the two codes ([1] code with getppid(), getpid(), [2] code...
Fantastic news! We've Found the answer you've been seeking!
Question:
Transcribed Image Text:
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 <sys/types.h>. 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 <stdio.h> #include <unistd.h> int main () { } printf ("The process ID is %d\n", (int) getpid ()); printf ("The parent process ID is %d\n", (int) getppid ()); return 0; Creating Processes Using system Listing 3.2 (system.c) Using the system Call #include <stdlib.h> 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. 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 <sys/types.h>. 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 <stdio.h> #include <unistd.h> int main () { } printf ("The process ID is %d\n", (int) getpid ()); printf ("The parent process ID is %d\n", (int) getppid ()); return 0; Creating Processes Using system Listing 3.2 (system.c) Using the system Call #include <stdlib.h> 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.
Expert Answer:
Answer rating: 100% (QA)
As per your given assignment you need to combine the codes from Listing 31 related to getpid and get... View the full answer
Related Book For
Income Tax Fundamentals 2013
ISBN: 9781285586618
31st Edition
Authors: Gerald E. Whittenburg, Martha Altus Buller, Steven L Gill
Posted Date:
Students also viewed these programming questions
-
Personal mobile devices now are used to carry out work related tasks and there are various mobile deployment options that companies can apply. Discuss the mobile deployment options that exist. Which...
-
* * * [Octavio] Sanchez works as a delivery driver at a Dominos Pizza restaurant owned by Western Pizza. He drives his own car in making deliveries. His hourly wage has ranged from the legal minimum...
-
Planning is one of the most important management functions in any business. A front office managers first step in planning should involve determine the departments goals. Planning also includes...
-
Happy Hands Company has net profit margin 5.51%, total assets turnover 0.63, and equity multiplier 2.77. What is its return on shareholder equity (ROE) using DuPont analysis method
-
Determine the horizontal and vertical components of force that the pins A and B exert on the two-member frame. Given: w = 400N/m a = 1.5 m b = 1 m c = 1 m F = 500 N = 60 deg
-
When provided copies of the results as a justification for distributing the bonus to the St. Bernard employees, the plant controllers at Norwood and Hartwell accused St. Bernard of manipulating the...
-
Table B. 11 presents data on the quality of Pinot Noir wine. a. Build an appropriate regression model for quality \(y\) using the all-possibleregressions approach. Use \(C_{p}\) as the model...
-
At the beginning of the current season on November 1, the ledger of Winona Sports showed Cash $3,300, Inventory $4,700, and Common Stock $8,000. The following transactions occurred during November...
-
According to the ideas behind the revenue recognition standard of the FASB, when a seller enters into a contract with a buyer, the seller accepts certain performance obligations in exchange for the...
-
"I'll never understand this accounting stuff," Blake Dunn yelled, waving the income statement he had just received from his accountant in the morning mail. "Last month, we sold 1,000 stuffed State...
-
a. The constants K and a satisfy the constraints K> 1 and a 20. The closed-loop transfer function K s+k+a Y(s) is T (s) = R(s) What is the half-power (-3 dB) bandwidth (rad/s) of the closed-loop...
-
Do you think that the overall international legal framework of biodiversity is inadequate in the rule that it sets out?
-
10 0.74 Use a calculator to evaluate each expression. Round your answers to three decimal places.
-
State the definition of a logarithm.
-
log 4 64 = 3 Change each logarithmic expression to an equivalent expression involving an exponent.
-
In a certain card game, the probability that a player is dealt a particular hand is 0.48. Explain what this probability means. If you play this card game 100 times, will you be dealt this hand...
-
Complete the following: Note: Round your answers to the nearest hundredth. $ Average Inventory at Cost Average Inventory at Retail 13,400 $ 20,940 $ Net Sales Cost of Goods Sold 67,000 $ 46,800...
-
What is the mode?
-
Charlie's Green Lawn Care is a cash basis taxpayer. Charlie Adame, the sole proprietor, is considering delaying some of his December 2012 customer billings for lawn care into the next year. In...
-
On September 14, 2012, Jay purchased a passenger automobile that is used 75 percent in his accounting business. The automobile has a basis for depreciation purposes of $35,000, and Jay uses the...
-
Ray and Maria Gomez have been married 3 years. They live at 1610 Quince Ave., McAllen, TX 78701. Ray works for Palm Oil Corporation and Maria works for the City of McAllen. Maria's Social Security...
-
Why is the bar chart not an adequate planning and scheduling tool?
-
Since the bar chart is ineffective as a planning and scheduling tool, why is it still widely used in the construction industry?
-
For the CPM Calculation Exercise found on the companion website, determine the ES, EF, LS, LF, FF, and TF for each activity. Identify the activities through which the critical path runs. How many...
Study smarter with the SolutionInn App