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
Concept explainers
Question
Chapter 10, Problem 10.7HW
Program Plan Intro
RIO Buffered Input functions:
- The RIO function is used to copy a text file from standard input to standard output one at a time.
- Rio functions are motivated by the three functions
- “readline” function
- “readn” function
- “writen” function
- The “rio_readn” and “rio_writen” functions are similar to the Stevens “readn” and “writen” functions.
Expert Solution & Answer
Want to see the full answer?
Check out a sample textbook solutionStudents have asked these similar questions
Assume that the followings are the outputs of ps and jobs commands and answer the following questions according to these outputs.
ps
jobs
PID TTY TIME CMD
6417 pts/0 00:00:00 bash
6458 pts/0 00:00:00 sleep
6459 pts/0 00:00:00 bash
6460 pts/0 00:00:00 sleep
6468 pts/0 00:00:00 cat
6469 pts/0 00:00:00 ps
[1] Running sleep 5000 &
[2]- Running (sleep 250; echo "Hello") &
[3]+ Stopped cat >list.txt
2.
What are the process ID no, job number, and status of the command “sleep 5000”
Process ID:
Job no:
Status:
3.
Write the necessary command line to restart (foreground) the third job in the job list.
Write a program, in assembly language format, to hold a character set at a specific memory location. Each character is entered via the keyboard and ends with the character '!'. Furthermore, the set of characters that have been stored in memory is displayed on the monitor screen. Hint: use the interrupts mentioned in question no 2 above. For example: from the keyboard type 'I', 'L', 'K', 'O', 'M', '!' ; then save it in a certain memory location and the screen display becomes ILKOM. Instructions: create a program in the form of procedures.
BELOW MCQ GIVEN ANSWER CAN BE MORE THAN ONE OPTION. PLEASE PROVIDE CORRECT ANSWERS.
-------------------
Q3 :- The ANSI C function below causes the program in which it runs to malfunction . Which of the following connection will help to perform function successfully ?
/* Return a count of all the bits set in bytes */
int bitcount (unsigned char c)
{
unsigned char x , b , count =0;
for (b = 0 , x= 1 ; !(x & 0x100); ++b, x <<=1) {
if (x | c )
++count;
}
return count;
}
A) change the type of x to a type larger than unsigned char.
B) remove the extraneous variable b.
C) change the return type to unsigned char .
D) change if ( x | c) to if ( x & c) inside the for loop.
E) change ! (c & 0x100) to ( x < 0x100) inside the for loop.
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
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
- provide the linux c output screenshot for the code below: include <bits/stdc++.h> using namespace std; #define totalprocess 5 struct process{int at,bt,pr,pno;}; process proc[50]; bool comp(process a,process b){if(a.at == b.at){return a.pr<b.pr;}else{ return a.at<b.at;}} void get_wt_time(int wt[]){ int service[50]; service[0] = proc[0].at;wt[0]=0; for(int i=1;i<totalprocess;i++){service[i]=proc[i-1].bt+service[i-1]; wt[i]=service[i]-proc[i].at; if(wt[i]<0) { wt[i]=0; }} } void get_tat_time(int tat[],int wt[]){ for(int i=0;i<totalprocess;i++){ tat[i]=proc[i].bt+wt[i];} } void findgc(){ int wt[50],tat[50]; double wavg=0,tavg=0; get_wt_time(wt); get_tat_time(tat,wt); int stime[50],ctime[50]; stime[0] = proc[0].at;ctime[0]=stime[0]+tat[0]; for(int i=1;i<totalprocess;i++) { stime[i]=ctime[i-1]; ctime[i]=stime[i]+tat[i]-wt[i]; }…arrow_forwardMIPS Assembly: Below is the code and attached is the syntax error it has. Please fix the syntax error and print the output. Attached is image of what the output must be. Data.asm .dataarr: .word 7, 9, 4, 3, 8, 1, 6, 2, 5n: .word 9 n .text.globl mainmain:la $t0, arr # Load address of arrla $t1, n # Load address of nlw $t2, 0($t1) # Load n into $t2 jal radixSort # Call radixSort la $a0, arr # Load address of arrlw $a1, 0($t1) # Load n into $a1jal printData # Call printData li $v0, 10 # Exit the programsyscallradixSort:la $a0, arr # Load address of arrlw $a1, 0($t1) # Load n into $a1 jal getMax # Call getMax move $t3, $v0 # Move the max to $t3move $t4, $zero # Move 0 to $t4 loop:ble $t3, $zero, Exit # Check if m/exp <= 0 mul $t5, $t4, 10 # Multiply exp by 10jal countSort # Call countSort addi $t4, $t4, 1 # Increment expdiv $t3, $t3, 10 # Divide m by 10j loop # Loop back Exit:jr $ra # ReturngetMax:move $t6, $zero # Move 0 to…arrow_forwardI am still getting the wrong output with the updated code with the fix. This is the updated coded that you provided: .data .globl main .textmain: # compute the next state of the LFSR for each input state li $a0, 0x00000001 jal lfsr_next_state move $t0, $v0 li $a0, 0xdeadbeef jal lfsr_next_state move $t1, $v0 li $a0, 0x200214c8 jal lfsr_next_state move $t2, $v0 li $a0, 0x00000000 jal lfsr_next_state move $t3, $v0 # print the output states li $v0, 1 move $a0, $t0 syscall li $v0, 1 move $a0, $t1 syscall li $v0, 1 move $a0, $t2 syscall li $v0, 1 move $a0, $t3 syscall # exit the program li $v0, 10 syscall # Function to compute the next state of an LFSR# Input parameter: $a0 = current state# Output: $v0 = next statelfsr_next_state: # Initialize upper mask with…arrow_forward
- Write a program to multiply the contents of the PINB by the contents of the RAM location 0x600 and store the lower and the higher bytes of the result in the RAM locations 0x500 and 0x501 simultaneously LDI R16, blank blank DDRB, R16 blank blank , PINB blank R16, blank blank R10, R16 blank 0x500, blank blank 0x501,arrow_forwardC codes on the following Read and Write? Read a byte (into TMP, where TMP is at GPR address = 0X60)) from GPR at address 0X1C3 (Bank 3)arrow_forwardWrite a parallel program using MPI (and not OpeMP) to accomplish the same as the following serial program. For the following serial program the user enters a line and the program outputs the number of occurrences of each printable character (but not the space or tab character). For the parallel program if we have p processes we should divide the line into p segments and let each process counts the characters of its segment#include<stdio.h>#include<stdlib.h>#include <string.h>#define ASCIIs 127 //ASCII characters from 0 to 127define atmost 1000char letters[atmost + 1]; //Extra location for the string terminator '\0'int total_count[ASCIIs];void find(int count[],int start, int end);int main(){ int i, processes, n, start, end; int count[ASCIIs], my_rank, segment, p;printf("Enter a line not larger than 1000 characters.\n");fgets(letters, atmost,stdin);printf("How many segments?: ");scanf("%d", &processes);//To make the length of the divisible by…arrow_forward
- How do I change this mips assembly code from Fahrenheit to Celsius to Celsius to Fahrenheit? # mips program .data prompt: .asciiz "Temperature (F) : " message: .asciiz "Temperature (C) : " C: .float 0.0 F: .float 0.0 const1: .float 32.0 const2: .float 5.0 const3: .float 9.0.text main: # printing the message to take input in F li $v0, 4 la $a0, prompt syscall # getting input from user li $v0, 6 syscall # loading constant values in registers l.s $f1, const1 l.s $f2, const2 l.s $f3, const3 # now calculating temperature in C sub.s $f0, $f0, $f1 mul.s $f0, $f0, $f2 div.s $f0, $f0, $f3 # printing the converted temperature in C li $v0, 4 la $a0, message syscall li $v0, 2 mov.s $f12, $f0 syscallarrow_forwardThe output I got is 32768. Then after that line are next three lines of "(null)" with error message "Memory address out of bounds." This is the updated code that you provided: .datanewline: .asciiz "\n" .globl main .textmain: # compute the next state of the LFSR for each input state li $a0, 0x00000001 jal lfsr_next_state move $t0, $v0 li $a0, 0xdeadbeef jal lfsr_next_state move $t1, $v0 li $a0, 0x200214c8 jal lfsr_next_state move $t2, $v0 li $a0, 0x00000000 jal lfsr_next_state move $t3, $v0 # print the output states li $v0, 1 # set system call for printing integer move $a0, $t0 syscall la $a0, newline li $v0, 4 # set system call for printing string syscall move $a0, $t1 syscall la $a0, newline syscall move $a0, $t2 syscall la $a0, newline syscall move $a0, $t3 syscall # exit the program li $v0, 10 syscall # Function to compute the next state of an LFSR# Input parameter: $a0…arrow_forwardPlease help with the following in regards to Nand2Tetris, and hack code, so hack assembly and hack vm. There can be more that one answer to a question if so please explain why. 1d. Given a function called foo() that calls another external function bar() which in turn calls a second function called additup(). Indicate the VM line of code indicating the location in the program that control should be return to: a.@Foo.$bar. b. @Foo$bar$additup.ret.1 c. @Foo.bar.additup.ret.1 d. @Foo$bar$additup&return e. @Foo return,bar return.additup 1e. The return value of a function when it is completed is stored, in: a. calling Frame Arg[?] b. calling Frame LCL c. calling Frame SP d. working Frame Arg[?] e. working Frame LCL f. working Frame SP g. none of the above 1f. Every boolean expression of N inputs and one output can be implemented Circle the letter for ALL that apply. a. using a combination of D flip-flops, multiplexors and registers. b. by connecting the output directly to all…arrow_forward
- Hello, I am practicing code in my Python book and I am struggling to define the submit and clear buttons for this Address Entry Form. It isn't working and states that they aren't defined. I also cannot get the 'sunken' effect look on the window frame. Can you help? My code is below. # Import tkinter import tkinter as tk # Define the submit button with a function def submit(): print("First Name: %s\nLast Name: %s\nAddress Line 1: %s\nAddress Line 2: %s\nCity: %s\nState/Province: %s\nCountry: %s" % (e1.get(), e2.get(), e3.get(), e4.get(), e5.get(), e6.get(), e7.get())) # Define the clear button with a function def clear(): e1.delete(0, 'end') e2.delete(0, 'end') e3.delete(0, 'end') e4.delete(0, 'end') e5.delete(0, 'end') e6.delete(0, 'end') e7.delete(0, 'end') # Create the master title master = tk.Tk()master.title("Address Entry Form") # Create the 'sunken' look for the window frame sunken_frame = tk.Frame(master, relief=tk.SUNKEN) # Create the labels…arrow_forwardModify the following program in lc-3 to get the input(numbers) from the keyboard and print the result to console. .ORIG x3000Loop LD R0, number1 ; load number1 into R0LDR R1, number2 ; load number2 into R1ST R2, SaveR2 ; save register R2LD R5, goSUB ; load address of SUB into R4JSRR R5 ; go to subroutine whose address in R5STR R3, result ; store resultLD R2, SaveR2 ; restore old value R2HALTnumber1 .FILL #10number2 .FILL # -8goSUB .FILL SUB ; initialize goSUB to address of SUBSaveR2 .BLKW #1; reserve space SaveR2 and SaveR3result .BLKW #1SUB NOT R1, R1ADD R2, R1, #1ADD R3, R0, R2RET.ENDarrow_forwardWrite a C program that emulates the logic of the memory management unit (MMU). The following are the requirements for the program: a.Prompt the user for a decimal number that will be used as the page size. Valid page sizes can either be 4095 (4K bytes) or 8191 (8K bytes). b.Display the page size to the console as a 16-bit binary number that displays each binary digit as a 1 or 0 with the least significant bit on the right side of the output. Also display the page size to the console as a hexadecimal number. c.Emulate a page table using a C array that supports the user specified page table size (you may create C arrays to handle a page table for both page sizes). The page table should represent a virtual memory address space of 1M bytes (0x000FFFFF) with a system that has a physical memory address size of 512K bytes (0x7FFFF), which is located at 0x00000000 and 0x0007FFFF. Populate the page table with the appropriate page table entries to support the specified page size and the…arrow_forward
arrow_back_ios
SEE MORE QUESTIONS
arrow_forward_ios
Recommended textbooks for you
- Database System ConceptsComputer ScienceISBN:9780078022159Author:Abraham Silberschatz Professor, Henry F. Korth, S. SudarshanPublisher:McGraw-Hill EducationStarting Out with Python (4th Edition)Computer ScienceISBN:9780134444321Author:Tony GaddisPublisher:PEARSONDigital Fundamentals (11th Edition)Computer ScienceISBN:9780132737968Author:Thomas L. FloydPublisher:PEARSON
- C How to Program (8th Edition)Computer ScienceISBN:9780133976892Author:Paul J. Deitel, Harvey DeitelPublisher:PEARSONDatabase Systems: Design, Implementation, & Manag...Computer ScienceISBN:9781337627900Author:Carlos Coronel, Steven MorrisPublisher:Cengage LearningProgrammable Logic ControllersComputer ScienceISBN:9780073373843Author:Frank D. PetruzellaPublisher:McGraw-Hill Education
Database System Concepts
Computer Science
ISBN:9780078022159
Author:Abraham Silberschatz Professor, Henry F. Korth, S. Sudarshan
Publisher:McGraw-Hill Education
Starting Out with Python (4th Edition)
Computer Science
ISBN:9780134444321
Author:Tony Gaddis
Publisher:PEARSON
Digital Fundamentals (11th Edition)
Computer Science
ISBN:9780132737968
Author:Thomas L. Floyd
Publisher:PEARSON
C How to Program (8th Edition)
Computer Science
ISBN:9780133976892
Author:Paul J. Deitel, Harvey Deitel
Publisher:PEARSON
Database Systems: Design, Implementation, & Manag...
Computer Science
ISBN:9781337627900
Author:Carlos Coronel, Steven Morris
Publisher:Cengage Learning
Programmable Logic Controllers
Computer Science
ISBN:9780073373843
Author:Frank D. Petruzella
Publisher:McGraw-Hill Education