COMPUTER SYSTEMS&MOD MSGT/ET SA AC PKG
3rd Edition
ISBN: 9780134671123
Author: Bryant
Publisher: PEARSON
expand_more
expand_more
format_list_bulleted
Question
Chapter 5.1, Problem 5.1PP
Program Plan Intro
Given C code:
void swap(long *xp, long *yp)
{
*xp = *xp + *yp;
*yp = *xp - *yp;
*xp = *xp - *yp;
}
Memory aliasing:
- It denotes a case where two pointers might designate to memory location that is same.
- The compiler should assume that unlike pointers might be aliased for safe optimizations.
- The program aspects that could limit chances for a compiler in generating optimized code denote optimization blockers.
- If a compiler is unable to determine whether two pointers might be aliased, it should adopt that either case would be possible.
- The possible optimization set is been limited in this case.
Expert Solution & Answer
Trending nowThis is a popular solution!
Students have asked these similar questions
Problem 1 jt"¡1, The following program is run on a machine where memory reference
instructions take 8 cycles, arithmetic instructions take 6 cycles, and branches take 3 cycles. It is
known that the “sqrt" procedure executes 7 instructions and requires 30 clock cycles.
$s0, 20 ($s2)
$t1, $s3, $s3
lw
add
j
L1
$t1, $t1, $t1
$t1, $t1, $6
$a0, 0 ($t1)
sqrt
addi $s3, $s3, 1
beq $s0, $v0, Exit
add
L1:
add
lw
jal
(a). How long will it take to run this program if the machine has a 500 MHz clock?
(b). What is the CPI for this program?
(a) A ssume that five generation unıts 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 tirst limes) such that units' charactenistics
and demand can be changed easily. Neglect grid losses.
O using lambda - iteration method.
Q1) Consider a simple traffic light system to regulate safe pedestrian crossing on a busy lane. Consider the following system requirement:(SysReq:)The traffic lights shall allow pedestrians to safely cross the lane by stopping cars
together with the following software requirements:
(SofReq1:)The light switch for pedestrians will be set to 'green' within x seconds after the pedestrian button has been pressed.
(SofReq2:)The light switch for cars will be set to 'red' at least y seconds before the light switch for pedestrians is set to 'green'.
Find missing environment assumptions and domain properties that are necessary to build the following satisfaction argument:
{SofReq1, SofReq2, assumptions?, domain properties?} =SysReq
Are the missing domain properties adequate? Are the missing assumptions realistic?
Chapter 5 Solutions
COMPUTER SYSTEMS&MOD MSGT/ET SA AC PKG
Knowledge Booster
Similar questions
- (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 longuage (MATLAB, C++, C+, Python,..) to calaulate economic load dispatch (ELD) using first order gradient method. Note that all parameters and variables should be defined program (at tirst lines such that units' charactenistics and demand can be changed easily. Neglect grid losses. o using second order gradient method. inside thearrow_forwardThe programming language: C++ The union of two ordered lists (Sequential linear list)[the solution introduction: The first video of in 3.1, 35:00-43:00] [Problem description] Give the union of two ordered lists. The maximal number of elements in an inputted set is 30. [Basic requirements] 1) Use sequential linear list. 2) The result list should also be ordered. [Example] Problem: Give the union of the ordered lists (3,4,9,100,103) and (7,9,43,53,102,105). What you need to show in the terminal(the back part is outputted by you and the blue part is inputted by the user, i.e., teacher): Please input the first ordered list: (3,4,9,100,103)Please input the second ordered list: (7,9,43,53,102,105) The union is: (3,4,7,9,9,43,53,100,102,103,105)arrow_forwardPROBLEM 21 - 0517: Write a subroutine which computes the roots of the quadratic equation a,x2 + a,x + a, = 0 according to the quadratic formula: X12 = (-az/2a,) + V[(a,/2a,)2 – (a,/a,)) (= [{a, + v(a?, - 4a,a,)} / 2a,]) (START SUBROUTINE QUAD COMPUTE, DISCRIMINANT (DISC) DISCarrow_forward4(c): Design an "unconventional" priority encoder as follows: It has 3 inputs D0, D1 and D2 and outputs A1, A0 and Valid. The input combination [D1,D0] = [11] is guaranteed to never happen, that is, both D1 and DO cannot be 1 at the same time. If D2 is 1, then the output code [A1A0]=[10]. Else it is either [01] or [00] depending on which of D1 or DO is logic 1. If any input is 1, Valid=1, else Valid=0. Give expressions for A1, A0 and Valid in terms of D0, D1 and D2. A1 = AO = Valid = You may DI Do yoo/01 use any lo 00 101 method you know to get your answer. Ai Ao Please draw any k-maps D2 00 01 10 used for partial credit (see below). It must be Valid. clear how you got your answer, i.e. show all "rough" work.arrow_forwardQuestion 2 Using the incomplete programming code given, complete the code using dynamic programming with memory function, to reproduce the results in the following Table 1. (C++) #include<iostream>using namespace std; // max knapsack capacity // *** WRITE YOUR CODE HERE ***// num of items // *** WRITE YOUR CODE HERE ***// weight of each item // *** WRITE YOUR CODE HERE ***// value of each item // *** WRITE YOUR CODE HERE ***// variable for dynamic programming matrix // *** WRITE YOUR CODE HERE *** //==========================================// Dynamic programming function: recursive// ========================================= // ALGORITHM F(i,j) // int value // if F[i,j] is not filled yet (-1): // (start with j = W, i = n) // if capacity j < current item's weight w[i]: // value = recall F(i-1, j) // else: // we can include current item,…arrow_forward[11] Convert each of the following expressions into sum of products and product of sums : (a) F = (AB+C)(B+CD) (b) F= x + x(x + y) (y + z) [12] Express the following functions as CSOP and CPOS expressions: (a) F(x,y,z) = (x+y+z)(x+z') + yz (b) F(w, x, y, z)=xy(wz+wz) (w+xz) in terms of x, y, and z in terms of w, x, y, and z [13] Given the following pulse trains for A, B and C, draw the pulse trains for F₁ and F2. B A C D F1 D Draw the answers here F2 B 0 F₁ A 1 F2 C 0 1 0 1 1 1 0 1 0 0 0 1 1 1 0 1 0 0 1 1arrow_forward(Greedy Algorithms) Suppose you are given n tasks j={j1,j2,...jn}.Each task jl has two parts -a preprocessing phase which takes pl unites and a main phase which takes fl units of time. There are n machines that can esecute the main phase of the jobs in parallel. However, the preprocessing phases need to be execute sequentially on a special machine. The completion time of any schedule is the earliest time when all tasks have finished execution. Design a greedy algorithm which produces a schedule the minimizes the completion time. Here, you need to give formal proof of correctnessarrow_forwardChapter 3: Practice Problems VIII. You are given the following C code to compute integer absolute value: int abs(int x) { } return x > (sizeof(int)*8-1); int comp = x mask; return comp; } A. What bit pattern does mask have, as a function of x? B. What numerical value does mask have, as a function of x? C. For what values of x do functions abs and opt abs return identical results? D. For the cases where they produce different results, how are the two results related? E. Show that with the addition of just one single arithmetic operation (any C operation is allowed) that you can fix opt abs. Show your modifications on the original code. (You can just provide the line that you will add). F. Are there any values of x such that abs returns a value that is not greater than 0? Which value(s)?arrow_forwardI need help with problem 17arrow_forwardProblem 1.10: Simplify F(A, B,C, D) = ACD+ A'B + D'arrow_forward4. Determine whether each distribution is a probability distributionarrow_forwardPROBLEM 24 - 0584: uses the modified Euler Write a FORTRAN program which method to simulate the growth of an isolated species from time t = 0 to t = tf, if the number of individuals at time t is N(t), N(0) = No and the rate of %3D population change (per unit of time), N, is given by: N = [K + E(t) - N/M)N] %D (1) where K and M are positive constants and E(t) is a periodic forcing input resulting from seasonal cycles, given by: Case 1: E(t) is sinusoidal with amplitude = A, period = 21/w, and phase angle p. Case 2: E(t) is a pulse train of width w, height, h and period Pw, P, h, w > 0, and starting at time t = t1 .arrow_forwardarrow_back_iosSEE MORE QUESTIONSarrow_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