EBK COMPUTER SYSTEMS
3rd Edition
ISBN: 8220101459107
Author: O'HALLARON
Publisher: YUZU
expand_more
expand_more
format_list_bulleted
Concept explainers
Question
Chapter 10.3, Problem 10.1PP
Program Plan Intro
Opening and Closing files:
Using “Open” function, a process can open an existing file or generates a new file.
- This function is used to converts a filename to a file descriptor and returns the result as a descriptor number.
- The descriptor returned is always the lowest descriptor that is not presently open in the process.
- Each process in the LINUX begins life with three open files.
- Descriptor 0 – standard input.
- Descriptor 1 – standard output.
- Descriptor 2 – standard error.
- The “open” function consists of three arguments. That is “Open(filename, flags, mode)”.
- The argument “filename” defines the name of the given file.
- The argument “flags” represents how the process plans to access the file. Some flags names are as follows.
- O_RDONLY – it means reading only.
- O_WRONLY – it means writing only.
- O_RDWR – it means reading and writing.
- The “mode” argument identifies the access permission bits of new files.
Example:
The example for open an existing file for reading is shown below:
sample1 = Open("foo1.txt", O_RDONLY, 0);
From the above “open” function,
- The filename is “foo1.txt”.
- Flag name is “O_RDONLY”.
- Mode is “0”.
Expert Solution & Answer
Want to see the full answer?
Check out a sample textbook solutionStudents have asked these similar questions
Problem 2 (5 pts)
Write a Python program that plays the game Ro-Sham-Bo (a.k.a., Rock, Paper, Scissors) for a player
and a computer opponent. The player selects one of the options listed in a console prompt, then the
computer randomly selects an option as well. The winner of the game is determined as follows:
Rock beats Scissors - Scissors beats Paper - Paper beats Rock
The same selection results in a tie.
Your program must do the following:
Prompt the player to enter a selection in the console. Provide instructions to user on what is
a valid input. For example, you can have the integers 1, 2, and 3 represent the selection, or
use the words rock, paper, scissors, etc.
Check that the user entered valid input. If the entry is invalid, the program needs to inform
the user of the invalid input and can end, or re-prompt the user for their entry.
Generate a random selection for the computer's choice. You can use a random integer and
follow the same rules as was stated to the user.
-
Display…
(a) Assume that five generation units with third order cost
function (F, (R) = A; P+ B;P+C; P; + D;) are in the circuit.
Write a computer program using any abitrary programming
longuage (MATLAB, C++, C#, Python,.) to calculate economic
load dipatch (ELD) using first order gradient method.
Note that all parameters and variables should be defined
inside the
program (at
tirst lines) such that units' characteristics
and demand can be changed easily. Neglect grid losses.
jusing dynamic programming (DP) methed.
1. (Shortest Path) Please find the shortest path between the blue triangle and red tri-
angle as Figure 1. Please explain your approach and develop the computationally
efficient algorithm to get the results. Can you obtain (or estimate) the time com-
plexity and memory complexity of your algorithm?
麗
Chapter 10 Solutions
EBK COMPUTER SYSTEMS
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
Learn more about
Need a deep-dive on the concept behind this application? Look no further. Learn more about this topic, computer-engineering and related others by exploring similar questions and additional content below.Similar questions
- (B+C) x (D+E) F 1. Write code to implement the expression: A = on 3-, 2-, 1- and 0-address machines. In accordance with programming language practice, computing the expression should not change the values of its operands. 2. Solve the following: a) In a computer instruction format, the instruction length is 11 bits and the size of an address field is 4 bits. Is it possible to have: 5 2-address instructions, 45 1-address instructions and 32 0-address instructions using the spec- ified format? Justify your answer. 3. Suppose a computer using direct mapped cache has 232 bytes of byte-addressable main memory and a cache size of 512 bytes, and each cache block contains 128 bytes. a) How many blocks of main memory are there? b) What is the format of a memory address as seen by cache, i.e., what are the sizes of the tag, block, and offset fields? c) To which cache block will the memory address 0x13A4498A map?arrow_forward(Chapter 10) Here again is the example used in our lecture to show the difference between scoping with blocks and dynamic scoping; fun g x = let val inc = 1; fun f y = y + inc; fun h z = let val inc = 2; in f z end; in h x end; Annotate it as follows: Draw a circle around every block, and number the blocks. Identify each definition of a name. For each definition, describe its scope in terms of your block numbers. For each occurrence of a name (other than a definition of that name), show which definition is used to bind it. Check that this agrees with your scopes.arrow_forward(C Program) Write a recursive function called PrintLinkedList() that outputs the integer value of each node in a linked list. Function PrintLinkedList() has one parameter, the head node of a list. The main program reads the size of the linked list, followed by the values in the list. Assume the linked list has at least 1 node.arrow_forward
- (a) Assume that five generation units with third order cost function (F: (P) = A: P²³ + B; P; ² + C; P; +D;) are in the circuit. Write a computer program using any arbitrary programming language (MATLAB, C++, C#, Python,...) to calculate economic. load dispatch (ELD) using first order gradient method. Note that all parameters and variables should be defined inside the program (at first lines) such that units' characteristics and demand can be changed easily. Neglect grid losses.arrow_forward(h) (Extra Credit!) Write a for-loop to implement a hill-climbing algorithm for the original constrained problem. Note that this algorithm must reflect the link be- tween small increases in x and y as captured through the constraint and so is поп-trivial.arrow_forward(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]) **************************arrow_forward
- 2) Implement the second phase of Software Development Method (SDM) for this following problem statement. Write a program to calculate and display the volume and surface area of a cube block. You also need to consider the following condition : The sides length must be greater than zero.arrow_forwardBy python, use functionsarrow_forward1. (Assembly Language Programming) Write a procedure gcd for finding the greatest common divisor (GCD) of two positive integers x and y, which is described in the C code below. int gcd (int x, int y) { if (y 0) == return x; else return gcd (y, x % y); } Assume that x and y are passed to procedure gcd via X4 and X5 and the result is returned in X2. Note that x % y is the remainder of x / y.arrow_forward
- (c). Two Computer Science students, Priscilla and Julius, are discussing how to compare two algorithms for solving a given problem. Priscilla suggests that they should use the execution times of the algorithms as criterion; but Julius insists that they should use the number of statements the algorithms execute as criterion. Discuss the reasons why both criteria they are considering are not good for comparing algorithms; and recommend an ideal solution/criterion that Priscilla and Julius should rather use for comparing algorithms.arrow_forward[Problem 4] Consider the sequence of integers 0, 1, 1, 7, 13, 55, 133, 463.. a) find the recursive function and initial conditions which generates them b) using the solution in part a), find the closed form solution for this sequence c) implement the recursive function in Pythonarrow_forward(QUESTION) Using the required programming language (python, matlab, etc.) plot the variation of pressure on the piston surface as a function of time until the piston moves 9 m, with the help of the following commands below. This problem will be solved for U_p =1, 4, 16, 64, 256 m/s. We'll assume that the time starts at t = 0 when the piston starts moving. (PLEASE TAKE A SCREENSHOT OF THE PLOTTING AND OTHER RESULTS.) Note: Since we don't have the exact time intervals or the rate at which the piston moves, we'll assume a constant speed and divide the distance by the speed to get the time taken. (QUESTION) COMMANDS import matplotlib.pyplot as plt import numpy as np # Given parameters diameter = 0.1 # meters length = 10 # meters initial_pressure = 10e3 # Pascals initial_temperature = 288 # Kelvin # Convert diameter to radius radius = diameter / 2 # Calculate initial and final volumes initial_volume = np.pi * radius**2 * length final_volume = np.pi * radius**2 * (length - 9) # Calculate…arrow_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