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 10.9, Problem 10.4PP
Program Plan Intro
“dup2” function:
- This function is used to copies the entry of old descriptor table to new descriptor table entry.
- Format for “dup2” function is given below,
int dup2(int oldFD, int newFD);
- From the above format, “oldFD” means old descriptor table entry and “newFD” means new descriptor table entry.
- It is used to copy the content of “oldFD” to “newFD”.
- If “newFD” was already open, then “dup2” function closes the “newFD” before it copies “oldFD”.
Example:
The example for “dup2” function is shown below:
Consider the function “dup2(4, 1)”.
- There are five file descriptors for given function that is “fd0”, “fd1”, “fd2”, “fd3”, and “fd4”. Each process in the LINUX begins life with three files they are
- File descriptor “fd0” – standard input
- File descriptor “fd1” – standard output
- File descriptor “fd2” – standard error
- For this function, assume two files such as “file A” and “file B”. Each file contains file table and v-node table.
- The entries in file table are file position and reference count.
- The entries in v-node table are file access, file size and file type.
- Before calling “dup2(4, 1)”:
- The “fd1” points to “file A” and “fd4” points to “file B”.
- The reference count for both files are equal to “1”.
- After calling “dup2(4, 1)”:
- Both “fd1” and “fd2” corresponds to “file B”.
- The “file A” has been closed and the entries in file table and v-node table of “file A” deleted.
- The reference count for “file B” is incremented that is now reference count is “2”.
- From the above description, any data written to standard output are redirected to “file B”.
Expert Solution & Answer
Want to see the full answer?
Check out a sample textbook solutionStudents have asked these similar questions
Problem 2. Evaluate the expressions in each of the following triples:
(c) 3 (mod4) = 10 (mod4) = 3·10 (mod4) =
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.
Problem 10
Chapter 10 Solutions
Computer Systems: A Programmer's Perspective (3rd Edition)
Ch. 10.3 - Prob. 10.1PPCh. 10.8 - Practice Problem 10.2 (solution page 915) Suppose...Ch. 10.8 - Practice Problem 10.3 (solution page 915) As...Ch. 10.9 - Prob. 10.4PPCh. 10.9 - Practice Problem 10.5 (solution page 916) Assuming...Ch. 10 - Prob. 10.6HWCh. 10 - Prob. 10.7HWCh. 10 - Write a version of the statcheck program in Figure...Ch. 10 - Consider the following invocation of the...Ch. 10 - Prob. 10.10HW
Knowledge Booster
Similar questions
- (Practice) Run Program 7.10 to determine the average and standard deviation of the following list of 15 grades: 68, 72, 78, 69, 85, 98, 95, 75, 77, 82, 84, 91, 89, 65, and 74.arrow_forward4. Look up the Pythagorean theorem if you are not already familiar with it. Use the following formula to solve for c in the formula: c = √a2 + b2. Use the proper functions from the cmath header file. Be sure to output the result..arrow_forward21. Take a careful look at Fig. 6-11(b). If D asks for one more unit, does this lead to a safe state or an unsafe one? What if the request came from C instead of D?arrow_forward
- 1.BL=00, after instruction DEC BL is executed, CF =? 2.CH=80H; after ROL CH, 1; CH=?arrow_forwardQ.) Do given c and d problem belowarrow_forward3. Simplify the following Boolean functions, using four-variable Kmaps: (a) F (w, x, y, z) = Σ(1, 4, 5, 6, 12, 14, 15) (b) F (A, B, C, D) = Σ(2, 3, 6, 7, 12, 13, 14) (c) F (w, x, y, z) = Σ(1, 3, 4, 5, 6, 7, 9, 11, 13, 15)arrow_forward
- (Physics) a. Design, write, compile, and run a C++ program to calculate the elapsed time it takes to make a 183.67-mile trip. This is the formula for computing elapsed time: elapsedtime=totaldistance/averagespeed The average speed during the trip is 58 mph. b. Manually check the values computed by your program. After verifying that your program is working correctly, modify it to determine the elapsed time it takes to make a 372-mile trip at an average speed of 67 mph.arrow_forwardDo problem 4. Cahaoter 1.arrow_forwardPlease provide me a machine problem one for each of these belowarrow_forward
- need to develop a MARIE code using C++. Please Help. For example, Create Two variables X,Y, and Z. Get Two INPUTS stored in X and Y. (Z = X + Y) Store Z, Halt. OUTPUT: X is 5, Y is 2arrow_forwardProblem 2 part aarrow_forward(Practice) State whether the following variable names are valid. If they are invalid, state the reason. prod_a c1234 abcd _c3 12345 newamp watts $total new$al a1b2c3d4 9ab6 sum.of average volts1 finvoltarrow_forward
arrow_back_ios
SEE MORE QUESTIONS
arrow_forward_ios
Recommended textbooks for you
- C++ for Engineers and ScientistsComputer ScienceISBN:9781133187844Author:Bronson, Gary J.Publisher:Course Technology Ptr
C++ for Engineers and Scientists
Computer Science
ISBN:9781133187844
Author:Bronson, Gary J.
Publisher:Course Technology Ptr