| Task | Deadline | ||
| Computer Structure, OS Structure | Thursday, Feb. 17, 2000 |
for ( i = 1 ; i <= 100 ; i++ ) X[i] = X[i] + S ; // X is an array and S is a // scalar
for ( i = 1 ; i <= 100 ; i++ ) Y[i] = Y[i] + Y[i+1]; // Y is an array
for ( i = 1 ; i <= 100 ; i++ ) { // Hint: You can make this
// loop parallel
A[i] = A[i] + B[i];
B[i+1] = C[i] + D[i]; // A, B, C and D are arrays
}
---------------------------------------------------------------
Process A Process B
---------------------------------------------------------------
while True do while True do
na = na + 1 ; nb = nb + 1
end end
repeat
X := X + 1 ;
if (X = 20) then X := 0 ;
forever;
Starting from an initial value of 0, show that it is possible
for the value of X to increase beyond 20.
What can you do to ensure that the value of X does not go beyond 20?
[Points: 15]