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
(defmacro mac (start end)
`(dfs ,start ,end nil nil))
(defun dfs (current-state goal-state path &optional (solution-found nil))
(cond
((and solution-found (equal current-state goal-state))
(format t "Solution: ~A~%" (reverse path)))
((member current-state path)
nil)
(t
(let ((new-paths (generate-next-states current-state)))
(dolist (new-state new-paths)
(dfs new-state goal-state (cons current-state path) t))))))
(defun generate-next-states (state)
(let* ((m (car state))
(c (cadr state))
(b (caddr state))
(next-states '()))
(loop for m-move from 0 to m
do (loop for c-move from 0 to c
do (when (valid-move m-move c-move m c b)
(let* ((new-state (update-state state m-move c-move))
(missionaries-on-left (- m m-move))
(cannibals-on-left (- c c-move))…
(Use Python) Use the Design Recipe to write a function, print_histogram that consumes a list of numbers and prints a histogram graph using asterisks to represent each number in the list. Use one output line per number in the list. You may assume that only integers are passed to this function. Your function should ignore negative values.
Test
Result
print_histogram([ 2, 0, 4, 1])
** *****
print_histogram([10, 5, 3, -1, 8])
**************************
Please help!
(Java) The objective is to write a program that reads CSV data and emits HTML data. Theprogram should accept input line-by-line in CSV format and produceoutput line-by-line in HTML format. You may use Scanners but should not need any otherimports. Note that regular expressions are forbidden.
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
- (minesweeper) could you please help this program how An appealing user interface with an interactive CSS design, where squares areunveiled by mouse clicks? example code:<!DOCTYPE html><html><title>Mines</title><head><script src="minefield.js"></script><script>var minefield = null;function newGame() {minefield = new Minefield(10, 10, 10);print();}function check() {var x = document.getElementById("x").value;var y = document.getElementById("y").value;window.alert(minefield.symbol(x, y));}function hit() {var x = document.getElementById("x").value;var y = document.getElementById("y").value;minefield.unveil(x, y);print();}function print() {var remaining = minefield.veiled + minefield.explosions - 10;document.getElementById("output").innerHTML =minefield.toString() + "\n" + remaining + "/" + minefield.explosions;}</script></head><body><pre id="output"></pre><p><input type="number" id="x" value = "0" min="0"…arrow_forward3. (Tabular Output) Write a Java application that uses looping to print the following table of(Exercise 4.22) values: 1 4 9 16 25 1 8 27 64 125 1 16 81 256 625arrow_forwardQ2/A/ Design a Matlab code to evaluate the equation P(x) x3 + 3x? 9 at x is zeros(3)? Execute the code and return the result.arrow_forward
- (PYTHON) (Display matrix of 0s and 1s) Write a function that displays an n-by-n matrix using the following header: def printMatrix(n): Each element is 0 or 1, which is generated randomly. Write a test program that prompts the user to enter n and displays an n-by-n matrix. Here is a sample run:arrow_forward(python3) Use the "stats" method (as shown in the provided image) as well as an illustrative plot to determine whether the following statement is true or false: The mean and variance values will also be the same for the Poisson distribution.arrow_forward(In java please) ( NO TOY CLASS PLEASE READ INSTRUCTION OR DOWN VOTE PLEASE LOOK AT TWO IMAGES BELOW YOU NEED THEM TO FINISH) THIS A LinkNode structure or class which will have two attributes - a data attribute, and a pointer attribute to the next node. The data attribute of the LinkNode should be a reference/pointer of the Currency class of Lab 2. Do not make it an inner class or member structure to the SinglyLinkedList class of #2 below. A SinglyLinkedList class which will be composed of three attributes - a count attribute, a LinkNode pointer/reference attribute named as and pointing to the start of the list and a LinkNode pointer/reference attribute named as and pointing to the end of the list. Since this is a class, make sure all these attributes are private. The class and attribute names for the node and linked list are the words in bold in #1 and #2. For the Linked List, implement the following linked-list behaviors as explained in class -…arrow_forward
- (Run-time environment) Draw a possible organization for the runtime environment of the following C program, similar to the given figure below. 1. after entry into block A in function f.2. after entry into block B in function g. PLEASE SHOW IT CLEARLY WITH THE EXPLANATION. THANK YOU.arrow_forward(Display patterns using loops) Use nested loops that display the following patterns in two separateprograms: pattern A Pattern B Pattern c 123456 1 3 1 6 1 2 3 3 3 1 6 1 2 3 4 5 3 3 3 1 6 1 2 3 4 5 6 7 3 3 1 6 1 2 3 4 5 6 7 8 9 3 123456arrow_forward(Exhaustive Search: The Assignment Problem) Complete the application of exhaustive search to The following assignment: [9 2 7 8] 64 37 5818 769 4 C = 1, 2, 3, 4 1, 2, 4, 3 1, 3, 2, 4 1, 3, 4, 2 1, 4, 2, 3 1, 4, 3, 2 Complete the remaining cases: Answer: cost = 9+4+1+4 = 18 cost = 9+4+8+9 = 30 cost = 9+3+8+4 = 24 cost = 9+3+8+6 = 26 cost = 9+7+8+9 = 33 cost = 9+7+1+6 = 23arrow_forward
- Please write a C++ coding with modularity using functions. 15. (Numerical) a. Euclid’s method for finding the greatest common divisor (GCD) of two positive integers consists of the following steps:Step 1: Divide the larger number by the smaller and retain the remainder.Step 2: Divide the smaller number by the remainder, again retaining the remainder.Step 3: Continue dividing the previous remainder by the current remainder until the remainder is zero, at which point the last non-zero remainder is the GCD. For example, if the two positive integers are 84 and 49, you have the following: Step 1: 84/49 yields a remainder of 35.Step 2: 49/35 yields a remainder of 14.Step 3: 35/14 yields a remainder of 7.Step 3: 14/7 yields a remainder of 0. Therefore, the last non-zero remainder, which is 7, is the GCD of 84 and 49.Using Euclid’s algorithm, replace the stub function written for Exercise 14 with an actual function that determines and returns the GCD of its two integer arguments. thank you…arrow_forwardQ3) Implement the Half Adder function using 2-LUT's only?arrow_forward( C PROGRAMMING ONLY) 5. Simplicity is Beautyby CodeChum Admin In life, simplicity is beauty. Let's try creating something so simple. Let's create a function that accepts the address of an integer and prints n number of asterisks out of it. For example, if the value of the address passed is 5, then the output would be five asterisks in one line. Instructions: In the code editor, you are provided with a main() function that asks the user for an integer and passes the address of this integer to a function call of the simple() function.This simple() function hasn't been implemented yet so your task is just that, to implement it. This has the following description:Return type - voidName - simpleParameter - address of an integerDescription - prints a line of asterisksDO NOT EDIT THE MAIN FUNCTIONInput 1. An integer Output Enter·n:·5*****arrow_forward
arrow_back_ios
SEE MORE QUESTIONS
arrow_forward_ios
Recommended textbooks for you
- C++ Programming: From Problem Analysis to Program...Computer ScienceISBN:9781337102087Author:D. S. MalikPublisher:Cengage Learning
C++ Programming: From Problem Analysis to Program...
Computer Science
ISBN:9781337102087
Author:D. S. Malik
Publisher:Cengage Learning