1. Describe the purpose of a buffer and give an example from your own experience
ID: 3774541 • Letter: 1
Question
1. Describe the purpose of a buffer and give an example from your own experience where its use clearly benefits system response.
2. Rewrite each of the following arithmetic expressions to take advantage of concurrent processing. Use the terms COBEGIN and COEND to delimit the sections of concurrent code. (see example on page 193)
a. A + B * R * Z – N * M + C2
b. (X * (Y * Z * W * R) + M + N + P)
c. ((J + K * L * M * N) * I)
3. Rewrite each of the following expressions for concurrent processing. Use the terms COBEGIN and COEND to delimit the sections of concurrent code. Identify which expressions, if any, might not run faster in a concurrent processing environment.
a. H2 * (O* (N + T))
b. X * (Y * Z * W * R)
c. M * T * R
Explanation / Answer
1) Buffers are used whenever data is received in sizes that may be different than the ideal size for the hardware or
software that uses the buffer. For example, a 64-bit processor on a 16-bit bus may have a buffer to hold 16-bit
requests until they equal 64-bits. Another use of buffers is to keep hardware from getting overwhelmed with
information. In that scenario, you use a large buffer to hold data until a device or program is ready to receive it,
instead of just pushing it onto a device that might not be ready. Buffers must be optimized in size to work
efficiently for the purpose they are designed.
An example from your own experience:
When letters are typed on keybaord in MS DOS program (Like a command prompt), these are line buffered until
carriage return is pressed. The keyboard buffer stores the data temporarily and this data is transferred to the input
output controller when it has a meaning.
This increases the responsiveness of the command prompt. If there is no keyboard buffer, the over all
responsiveness would be decreased. As each letter would be passed to controlller for processing and the control
would revert back to keyboard involving overheads.
2)
a. A + B * R * Z - N * M + C²
COBEGIN
T1 = B*R*Z
T2=N*M
T3 = C*C
COEND
T4=A+T1
T5 = T2+T3
ANS = T4-T5
b. ( X * ( Y * Z * W * R ) + M + N + P )
COBEGIN
T1 = Y*Z
T2 = W*R
T3 = M+N
COEND
COBEGIN
T4 = T1*T2
T5 = P+T3
COEND
T6 = X*T4
ANS = T6+T5
c. ( ( J + K * L * M * N ) * I )
COBEGIN
T1 = K*L
T2 = M*N
COEND
T3 = T1*T2
T4 = J+T3
ANS = T4*I
3) By doing this we can get the result as follows:
[H2 * O], [N + T] => [H2 * O]*[N + T]
[Y * Z], [W * R] => [Y * Z] * [W * R] => [Y * Z * W * R] * X
[M * T], [T * R] => [M * T] * [T * R] => [M * T * T * R] / T
Related Questions
Navigate
Integrity-first tutoring: explanations and feedback only — we do not complete graded work. Learn more.