Using the following program, identify the values of pid at lines A, B, C, and D....
Fantastic news! We've Found the answer you've been seeking!
Question:
Transcribed Image Text:
Using the following program, identify the values of pid at lines A, B, C, and D. (Assume that the actual pids of the parent and child are 2600 and 2603, respectively. getpid() function returns the pid of the current process.) #include <sys/types.h> #include <stdio.h> #include <unistd.h> int main() pid_ t pid, pidl; * fork a child process */ pid = fork(); if (pid < 0) { * error occurred */ fprintf(stderr, "Fork Failed"); return 1; else if (pid =0) { * child process */ pidl = getpid(); printf"child: pid = %d",pid); /* A / printf"child: pidl = %d",pid1); /* B */ else { /* parent process */ pidl = getpid(); printf "parent: pid = %d",pid); /* C/ printf"parent: pid1 = %d",pid1); /*D*/ wait(NULL); return 0; Using the following program, identify the values of pid at lines A, B, C, and D. (Assume that the actual pids of the parent and child are 2600 and 2603, respectively. getpid() function returns the pid of the current process.) #include <sys/types.h> #include <stdio.h> #include <unistd.h> int main() pid_ t pid, pidl; * fork a child process */ pid = fork(); if (pid < 0) { * error occurred */ fprintf(stderr, "Fork Failed"); return 1; else if (pid =0) { * child process */ pidl = getpid(); printf"child: pid = %d",pid); /* A / printf"child: pidl = %d",pid1); /* B */ else { /* parent process */ pidl = getpid(); printf "parent: pid = %d",pid); /* C/ printf"parent: pid1 = %d",pid1); /*D*/ wait(NULL); return 0;
Expert Answer:
Answer rating: 100% (QA)
Problem 1 value of pid at A is 0 At A the code block has ... View the full answer
Related Book For
Fundamentals of Physics
ISBN: 978-0471758013
8th Extended edition
Authors: Jearl Walker, Halliday Resnick
Posted Date:
Students also viewed these accounting questions
-
Consider a project consisting of four activities A, B, C, and D. The following are constraints within which the project has to be conducted A and B, the first activities of the project, can be...
-
Explain why A B C and (A B) C are not the same.
-
Compile and run the program in Figure 9.6. Explain its behavior. Create a new version that behaves more predictably. #include #include #include char* days [7] = {"Sunday", "Monday", "Tuesday",...
-
Sunita inherits $45,000 from a distant relative. She decides to invest her inheritance in a diversified, dividend-paying mutual fund. At the time of her initial investment, she purchases 1,500 shares...
-
An investment of $1,500 is made for two years at 2% annual interest compounded semiannually. Find the compound amount and the compound interest at the end of two years?
-
Diagonalize \(e^{\sigma_{1}}\), where \(\sigma_{1}\) is the first Pauli matrix \(\left(\begin{array}{ll}0 & 1 \\ 1 & 0\end{array} ight)\).
-
A thin-walled composite tube having an outside diameter of \(48 \mathrm{~mm}\) is made by securely bonding an aluminum tube inside a steel tube, as shown in Figure 7.10. Determine the maximum...
-
Ridgecrest Electric manufactures electric motors. It competes and plans to grow by selling high- quality motors at a low price and by delivering them to customers quickly after receiving customers...
-
Minimum Spanning Tree problem (not in book): Consider the following undirected weighted graph. 1 a. List the edges that are in the minimum spanning tree that Kruskal's algorithm would find in the...
-
This case study requires you to use double entry manual recording to record transactions for September 2020. It covers many of the common transactions of everyday business, including GST.General...
-
Dante was arrested for driving under the influence of alcohol. At his trial, the prosecution sought to introduce the written report of Officer Beatrice, one of the arresting officers. Officer...
-
1. Jerseys, Inc., currently produces 10,000 jerseys a year for its regular customers and charges $10 per jersey. Jerseys, Inc., has capacity to produce an additional 5,000 jerseys if sales grow in...
-
Common Pollution Policy grant of 20 per cent of gross capital expenditure is available, with payment in the year following expenditure. A disadvantage of the new equipment is that it will raise...
-
Q1 Saturn PLC Saturn PLC is considering a capital investment of 2,500,000 in new, state of the art equipment, with a resale value of 750,000 in 3 years' time. The equipment will be used to...
-
Charitable Contribution In 2020, X Corporation contributed 100 shares of Y corporation stock to a qualified charity. The FMV of the stock was $100,000 and adjusted basis was $40,000. In 2022, X...
-
Private Equity Associates ("Associates") is a limited partnership that buys, restructures, and then sells companies that are not publicly traded. Manager, the sole general partner of Associates, is...
-
What strategies would you implement to foster a positive work culture within a diverse team?
-
Is the modified 5-question approach to ethical decision making superior to the modified moral standards or modified Past in approach?
-
(a) At what angle of incidence will the light reflected from water be completely polarized? (b) Does this angle depend on the wavelength of the light?
-
Block B in Figure weighs 711 N. The coefficient of static friction between block and table is 0.25; angle is 30 o ; assume that the cord between B and the knot is horizontal. Find the maximum weight...
-
The magnitude J of the current density in a certain wire with a circular cross section of radius R = 2.00 mm is given by J = (3.00 x 108) r2, with J in amperes per square meter and radial distance r...
-
(a) Is the magnitude of the gravitational force exerted by Earth on a ball greater than, equal to, or smaller than the magnitude of the gravitational force exerted by the ball on Earth? (b) Is the...
-
Two objects 1 and 2, of mass \(m_{1}\) and \(m_{2}\), are released from rest far from Earth, at a location where the magnitude of the acceleration due to gravity is much less than \(g=9.8 \mathrm{~m}...
-
A communications satellite orbits \(1.4 \times 10^{7} \mathrm{~m}\) from Earth's center, at a location where the magnitude of Earth's gravitational field is \(2.0 \mathrm{~N} / \mathrm{kg}\). (a) If...
Study smarter with the SolutionInn App