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
-
How does scaling relate to the fact that the heartbeat of large creatures is generally slower than the heartbeat of smaller creatures?
-
List your needs (including budget) and your wants for a new automobile. Consult sources such as Web sites, magazines, and dealership literature, and make a financially and personally wise decision...
-
The following information is available for October 2005. Beginning cash balance for October is expected to be \($60,000\). The company intends to maintain a cash balance of at least \($50,000\). The...
-
Radmore Memorial Hospital has a problem in its fluids analysis lab. The lab has available three machines that analyze various fluid samples. Recently, the demand for analyzing blood samples has...
-
Question 1 from below and upward. Input Area: 1 2 3 4 5 Net Income (after 2.65 2.75 3.25 3.65 4.00 tax) Total Operating Revenues 26.50 30.10 39.80 47.50 55.90 Total Assets 300.00 315.00 331.00 347.00...
-
The trial balance for the MAD Partnership is as follows just before declaring bankruptcy. Required: A. Prepare a schedule to show how available cash would be distributed to the partners after...
-
At the end of the current year, Singleton Inc. reported the following information: Sales $412,000 Operating income 163,000 Average total assets 475,000 Average stockholders' equity 365,000 Compute...
-
Steam at 15 bar and 350c is expanded through 0.75 the reheat factor a 50% reaction turbine to a pressure of 0.14 bar. the stage efficiency is is 1.04, the expansion is carried out in 20 stages and...
-
- To see if a number, say 562437487, is divisible by 3, you just add up the digits of its decimal representation, and see if the result is divisible by 3. (5+ 6+2+4+3+7+4+8+ 7 = 46, so it is not...
-
For the system y[n] = T{x[n]} = sin [n]x[n], does the system have the property: a. Linear b. Time-invariant c. Memoryless d. Causal e. BIBO Stable
-
A solid 1040 hot-rolled steel shaft 37.5 in long has a rectangular cross section of 2.5 in x 3.6 in. The shaft transmits a torque of 30 kip-in at an angular velocity of 500 rpm. NOTE: This is a...
-
A number of different types of flow chambers have been designed to study adhesion between cells in vitro. One important design feature is the ability to have a range of shear stresses. This ability...
-
c. VEI has the following investment opportunities that are average-risk projects: Project Cost at t Rate of = 0 Return A $10,000 17.4% BCDE 20,000 16.0 10,000 14.2 20,000 13.2 10,000 12.0 Which...
-
What steps must a business take to implement a program of social responsibility?
-
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...
-
On September 10, 2017, the Globe Trading Company invested \($3,000,000\) to establish a small sales subsidiary in Lima, Peru. The subsidiary converted \($3,000,000\) into 10,000,000 new sols (S/) and...
-
Consider two companies with subsidiaries in Venezuela, a country that has been identified as hyperinflationary. U.S. Marts reporting currency is the U.S. dollar, and it uses U.S. GAAP to consolidate...
-
Question: Troy owns an art gallery specializing in Greek artifacts. To modernize the gallery, Troy borrows $150,000 from the Sparta Bank, which takes a security interest in all of his inventory....
Study smarter with the SolutionInn App