Computer Systems: A Programmer's Perspective (3rd Edition)
3rd Edition
ISBN: 9780134092669
Author: Bryant, Randal E. Bryant, David R. O'Hallaron, David R., Randal E.; O'Hallaron, Bryant/O'hallaron
Publisher: PEARSON
expand_more
expand_more
format_list_bulleted
Question
Chapter 8.4, Problem 8.2PP
A.
Program Plan Intro
Given code:
//Include the necessary header files
#include <stdio.h>
#include "csapp.h"
//Define a main()
int main()
{
//Initialize the variable x as 1
int x=1;
//Check the condition
if(fork()==0)
//Print the statement
printf("p1: x=%d\n", ++x);
//Print the statement
printf("p2: x=%d\n", --x);
//Exit
exit(0);
}
Explanation:
The given code is used to print the output of the child and parent processes.
In the given code, the main
- The “if” condition check, function “fork()” is equal to zero.
- Condition is true, print the value of “x” by incrementing “1”. So, the value of “x” becomes “2”.
- Otherwise, print the value of “x” by decrementing “1”. So, the value of “x” becomes “1”.
- Exit from the program.
B.
Explanation of Solution
Output of the parent process:
P2: x = 0
Explanation:
In the given code, the main program initializes the variable “x” as “1”.
- The parent process check the condition, if the function “fork()” is equal to zero...
Expert Solution & Answer
Want to see the full answer?
Check out a sample textbook solutionStudents have asked these similar questions
Problem 3 (#2.1.32).Explain why (A×B)×(C×D)and A×(B×C)×D are not the same
3. The diagram below shows the main land routes for vehicular traffic between points A and G in a city. The figures in the arcs represent the cost of traveling between each pair of nodes.
a) Manually apply Dijkstra's algorithm to find the cheapest route between A and G (visited nodes and total distance).
b) Formulate a linear programming problem in extended form, to determine the shortest route to travel from A to G. Do not use subscripts, name 14 variables, for example XFE would be the variable that indicates that the arc from F to E is used.
c) If there is a fixed cost for visiting each node, modify the formulation of the problem to include said fixed cost in the objective function, and the variables and restrictions that are required.
NODE
A
B
C
D
E
F
G
FIXED COST
25
18
32
20
28
18
34
PROBLEM 12. [TIME ALLOWED = 5 MINUTES]
Give the contrapositive and converse of the following proposition:
“If it is sunny, then I will go swimming.”
Chapter 8 Solutions
Computer Systems: A Programmer's Perspective (3rd Edition)
Ch. 8.2 - Prob. 8.1PPCh. 8.4 - Prob. 8.2PPCh. 8.4 - Prob. 8.3PPCh. 8.4 - Prob. 8.4PPCh. 8.4 - Practice Problem 8.5 (solution page 797) Write a...Ch. 8.4 - Practice Problem 8.6 (solution page 797) Write a...Ch. 8.5 - Practice Problem 8.7 (solution page 798) Write a...Ch. 8.5 - Prob. 8.8PPCh. 8 - Prob. 8.9HWCh. 8 - In this chapter, we have introduced some functions...
Ch. 8 - How many hello output lines does this program...Ch. 8 - How many "hello' output lines does this program...Ch. 8 - Prob. 8.13HWCh. 8 - How many hello output lines does this program...Ch. 8 - How many "hello lines does this program print?Ch. 8 - Prob. 8.16HWCh. 8 - Prob. 8.17HWCh. 8 - Consider the following program: Determine which of...Ch. 8 - How many lines of output does the following...Ch. 8 - Use execve to write a program called my1s whose...Ch. 8 - What are the possible output sequences from the...Ch. 8 - Write your own version of the Unix system function...Ch. 8 - One of your colleagues is thinking of using...Ch. 8 - Modify the program in Figure 8.18 so that the...Ch. 8 - Write a version of the fgets function, called...
Knowledge Booster
Similar questions
- 4. Describe the requirements that need to be satisfied to solve the critical section problem. Give a solution to the critical section problem where there are 2 processes.arrow_forwardProblem 4 Discrete Mathematics.Combinations and Permutations. (5,10,10): Soccer A local high school soccer team has 20 players. However, only 11 players play at any given time during a game. In how many ways can the coach choose 11 players To be more realistic, the 11 players playing a game normally consist of 4 midfielders, 3 defend ers, 3 attackers and 1 goalkeeper. Assume that there are 7 midfielders, 6 defenders, 5 attackers and 2 goalkeepers on the team 2. In how many ways can the coach choose a group of 4 midfielders, 3 defenders, 3 attackers and 1 goalkeeper? 3. Assume that one of the defenders can also play attacker. Now in how many ways can the coach choose a group of 4 midfielders, 3 defenders, 3 attackers and 1 goalkeeper?arrow_forwardProblem 2 part aarrow_forward
- Problem 7arrow_forwardShow complete solution please. I am at a loss of how to even begin this problem and would like to learn how to work through each step.arrow_forwardPROBLEM 13. [TIME ALLOWED = 5 MINUTES] Give the contrapositive, converse, and inverse of the following proposition: “If the number is positive, then its square is positive.”arrow_forward
- 4.1.1 Complete solution and answer only no need explanation Given three data points (1,6), (3,28), and (10, 231), What is the value of y at x = 2 if the function y = 2x2 + 3x + 1 passes through the three data points.arrow_forward(b) A 10 pole, 125 HP, 575 V, 60 Hz, 3-ph induction motor operating at rated conditions draws a line current of 125 A and has an overall efficiency of 93%. The core loss, stator conductor loss and rotor conductor loss are 1053 W, 2527 W, and 1755 W respectively. Sketch the power flow diagram, substitute values and determine: (i) shaft speed; (ii) developed torque; (iii) shaft torque; (iv) power factor; (v) combined windage, friction, and stray power loss.arrow_forwardI need help with problem 40. What do I need to do?arrow_forward
- 5 Problem 1. List all the necessary components for a static game in normal form. After that list all the components of a dynamic game in extended form. Explain the differences and why they are necessarily present. Basically, a game in Normal form has 3 components, while a game in extended has 7 listed in video lectures. Your goal is to identify how are dynamic games different and which differences necessitate the additional components.arrow_forwardQ.) Do given c and d problem belowarrow_forwardPlease help me solve Part A of this problemarrow_forward
arrow_back_ios
SEE MORE QUESTIONS
arrow_forward_ios
Recommended textbooks for you
- Operations Research : Applications and AlgorithmsComputer ScienceISBN:9780534380588Author:Wayne L. WinstonPublisher:Brooks ColeC++ for Engineers and ScientistsComputer ScienceISBN:9781133187844Author:Bronson, Gary J.Publisher:Course Technology Ptr
Operations Research : Applications and Algorithms
Computer Science
ISBN:9780534380588
Author:Wayne L. Winston
Publisher:Brooks Cole
C++ for Engineers and Scientists
Computer Science
ISBN:9781133187844
Author:Bronson, Gary J.
Publisher:Course Technology Ptr