Computer Systems: A Programmer's Perspective (3rd Edition)
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
bartleby

Concept explainers

Question
Book Icon
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”.

Blurred answer
Students 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.
(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?
Knowledge Booster
Background pattern image
Computer Science
Learn more about
Need a deep-dive on the concept behind this application? Look no further. Learn more about this topic, computer-science and related others by exploring similar questions and additional content below.
Similar questions
SEE MORE QUESTIONS
Recommended textbooks for you
Text book image
C++ for Engineers and Scientists
Computer Science
ISBN:9781133187844
Author:Bronson, Gary J.
Publisher:Course Technology Ptr